Skip to content

Commit 11d3ba6

Browse files
committed
Remove unneeded logging
1 parent d1eaa39 commit 11d3ba6

29 files changed

+84
-168
lines changed

RetailCoder.VBE/App.cs

Lines changed: 20 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public sealed class App : IDisposable
3838
private readonly BranchesViewViewModel _branchesVM;
3939
private readonly SourceControlViewViewModel _sourceControlPanelVM;
4040

41-
private readonly Logger _logger;
41+
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
4242

4343
private VBProjectsEventsSink _sink;
4444
private Configuration _config;
@@ -67,7 +67,6 @@ public App(VBE vbe, IMessageBox messageBox,
6767
_appMenus = appMenus;
6868
_stateBar = stateBar;
6969
_hooks = hooks;
70-
_logger = LogManager.GetCurrentClassLogger();
7170

7271
var sourceControlPanel = (SourceControlPanel) sourceControlPresenter.Window();
7372
_sourceControlPanelVM = (SourceControlViewViewModel) sourceControlPanel.ViewModel;
@@ -221,7 +220,7 @@ async void sink_ProjectRemoved(object sender, DispatcherEventArgs<VBProject> e)
221220

222221
if (e.Item.Protection == vbext_ProjectProtection.vbext_pp_locked)
223222
{
224-
_logger.Debug("Locked project '{0}' was removed.", e.Item.Name);
223+
Logger.Debug("Locked project '{0}' was removed.", e.Item.Name);
225224
return;
226225
}
227226

@@ -235,7 +234,7 @@ async void sink_ProjectRemoved(object sender, DispatcherEventArgs<VBProject> e)
235234
_parser.State.RemoveProject(e.Item);
236235
_parser.State.OnParseRequested(this);
237236

238-
_logger.Debug("Project '{0}' was removed.", e.Item.Name);
237+
Logger.Debug("Project '{0}' was removed.", e.Item.Name);
239238
Tuple<IConnectionPoint, int> componentsTuple;
240239
if (_componentsEventsConnectionPoints.TryGetValue(projectId, out componentsTuple))
241240
{
@@ -261,10 +260,10 @@ async void sink_ProjectAdded(object sender, DispatcherEventArgs<VBProject> e)
261260
{
262261
if (!_handleSinkEvents || !_vbe.IsInDesignMode()) { return; }
263262

264-
_logger.Debug("Project '{0}' was added.", e.Item.Name);
263+
Logger.Debug("Project '{0}' was added.", e.Item.Name);
265264
if (e.Item.Protection == vbext_ProjectProtection.vbext_pp_locked)
266265
{
267-
_logger.Debug("Project is protected and will not be added to parser state.");
266+
Logger.Debug("Project is protected and will not be added to parser state.");
268267
return;
269268
}
270269

@@ -288,7 +287,7 @@ private void RegisterComponentsEventSink(VBComponents components, string project
288287
if (_componentsEventsSinks.ContainsKey(projectId))
289288
{
290289
// already registered - this is caused by the initial load+rename of a project in the VBE
291-
_logger.Debug("Components sink already registered.");
290+
Logger.Debug("Components sink already registered.");
292291
return;
293292
}
294293

@@ -311,7 +310,7 @@ private void RegisterComponentsEventSink(VBComponents components, string project
311310
connectionPoint.Advise(componentsSink, out cookie);
312311

313312
_componentsEventsConnectionPoints.Add(projectId, Tuple.Create(connectionPoint, cookie));
314-
_logger.Debug("Components sink registered and advising.");
313+
Logger.Debug("Components sink registered and advising.");
315314
}
316315

317316
async void sink_ComponentSelected(object sender, DispatcherEventArgs<VBComponent> e)
@@ -322,9 +321,8 @@ async void sink_ComponentSelected(object sender, DispatcherEventArgs<VBComponent
322321
{
323322
return;
324323
}
325-
326-
_logger.Debug("Component '{0}' was selected.", e.Item.Name);
327-
// do something?
324+
325+
// todo: keep Code Explorer in sync with Project Explorer
328326
}
329327

330328
async void sink_ComponentRenamed(object sender, DispatcherRenamedEventArgs<VBComponent> e)
@@ -340,7 +338,7 @@ async void sink_ComponentRenamed(object sender, DispatcherRenamedEventArgs<VBCom
340338

341339
_sourceControlPanelVM.HandleRenamedComponent(e.Item, e.OldName);
342340

343-
_logger.Debug("Component '{0}' was renamed to '{1}'.", e.OldName, e.Item.Name);
341+
Logger.Debug("Component '{0}' was renamed to '{1}'.", e.OldName, e.Item.Name);
344342

345343
var projectId = e.Item.Collection.Parent.HelpFile;
346344
var componentDeclaration = _parser.State.AllDeclarations.FirstOrDefault(f =>
@@ -359,7 +357,7 @@ async void sink_ComponentRenamed(object sender, DispatcherRenamedEventArgs<VBCom
359357
_referencesEventsSinks.Remove(projectId);
360358
_parser.State.RemoveProject(projectId);
361359

362-
_logger.Debug("Project '{0}' was removed.", e.Item.Name);
360+
Logger.Debug("Project '{0}' was removed.", e.Item.Name);
363361
Tuple<IConnectionPoint, int> componentsTuple;
364362
if (_componentsEventsConnectionPoints.TryGetValue(projectId, out componentsTuple))
365363
{
@@ -397,7 +395,7 @@ async void sink_ComponentRemoved(object sender, DispatcherEventArgs<VBComponent>
397395

398396
_sourceControlPanelVM.HandleRemovedComponent(e.Item);
399397

400-
_logger.Debug("Component '{0}' was removed.", e.Item.Name);
398+
Logger.Debug("Component '{0}' was removed.", e.Item.Name);
401399
_parser.State.ClearStateCache(e.Item, true);
402400
}
403401

@@ -411,8 +409,7 @@ async void sink_ComponentReloaded(object sender, DispatcherEventArgs<VBComponent
411409
}
412410

413411
_parser.Cancel(e.Item);
414-
415-
_logger.Debug("Component '{0}' was reloaded.", e.Item.Name);
412+
416413
_parser.State.OnParseRequested(sender, e.Item);
417414
}
418415

@@ -427,7 +424,7 @@ async void sink_ComponentAdded(object sender, DispatcherEventArgs<VBComponent> e
427424

428425
_sourceControlPanelVM.HandleAddedComponent(e.Item);
429426

430-
_logger.Debug("Component '{0}' was added.", e.Item.Name);
427+
Logger.Debug("Component '{0}' was added.", e.Item.Name);
431428
_parser.State.OnParseRequested(sender, e.Item);
432429
}
433430

@@ -439,8 +436,7 @@ async void sink_ComponentActivated(object sender, DispatcherEventArgs<VBComponen
439436
{
440437
return;
441438
}
442-
443-
_logger.Debug("Component '{0}' was activated.", e.Item.Name);
439+
444440
// do something?
445441
}
446442

@@ -455,7 +451,7 @@ async void sink_ProjectRenamed(object sender, DispatcherRenamedEventArgs<VBProje
455451

456452
_parser.Cancel();
457453

458-
_logger.Debug("Project '{0}' (ID {1}) was renamed to '{2}'.", e.OldName, e.Item.HelpFile, e.Item.Name);
454+
Logger.Debug("Project '{0}' (ID {1}) was renamed to '{2}'.", e.OldName, e.Item.HelpFile, e.Item.Name);
459455

460456
_parser.State.RemoveProject(e.Item.HelpFile);
461457
_parser.State.AddProject(e.Item);
@@ -471,9 +467,8 @@ async void sink_ProjectActivated(object sender, DispatcherEventArgs<VBProject> e
471467
{
472468
return;
473469
}
474-
475-
_logger.Debug("Project '{0}' was activated.", e.Item.Name);
476-
// do something?
470+
471+
// todo: keep Code Explorer in sync with Project Explorer
477472
}
478473
#endregion
479474

@@ -485,13 +480,12 @@ private void _stateBar_Refresh(object sender, EventArgs e)
485480

486481
private void Parser_StateChanged(object sender, EventArgs e)
487482
{
488-
_logger.Debug("App handles StateChanged ({0}), evaluating menu states...", _parser.State.Status);
483+
Logger.Debug("App handles StateChanged ({0}), evaluating menu states...", _parser.State.Status);
489484
_appMenus.EvaluateCanExecute(_parser.State);
490485
}
491486

492487
private void LoadConfig()
493488
{
494-
_logger.Debug("Loading configuration");
495489
_config = _configService.LoadConfiguration();
496490

497491
var currentCulture = RubberduckUI.Culture;
@@ -502,7 +496,7 @@ private void LoadConfig()
502496
}
503497
catch (CultureNotFoundException exception)
504498
{
505-
_logger.Error(exception, "Error Setting Culture for Rubberduck");
499+
Logger.Error(exception, "Error Setting Culture for Rubberduck");
506500
_messageBox.Show(exception.Message, "Rubberduck", MessageBoxButtons.OK, MessageBoxIcon.Error);
507501
_config.UserSettings.GeneralSettings.Language.Code = currentCulture.Name;
508502
_configService.SaveConfiguration(_config);

RetailCoder.VBE/Common/Hotkeys/Hotkey.cs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
using System.Windows.Input;
55
using Rubberduck.Common.WinAPI;
66
using NLog;
7+
using Rubberduck.UI;
78
using Rubberduck.UI.Command;
89

910
namespace Rubberduck.Common.Hotkeys
@@ -13,7 +14,7 @@ public class Hotkey : IHotkey
1314
private readonly string _key;
1415
private readonly ICommand _command;
1516
private readonly IntPtr _hWndVbe;
16-
private static readonly Logger _logger = LogManager.GetCurrentClassLogger();
17+
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
1718

1819
public Hotkey(IntPtr hWndVbe, string key, ICommand command, Keys secondKey = Keys.None)
1920
{
@@ -86,14 +87,11 @@ private void HookKey(Keys key, uint shift)
8687
var success = User32.RegisterHotKey(_hWndVbe, hookId, shift, (uint)key);
8788
if (!success)
8889
{
89-
_logger.Debug(Rubberduck.UI.RubberduckUI.CommonHotkey_KeyNotRegistered, key);
90-
//throw new Win32Exception(Rubberduck.UI.RubberduckUI.CommonHotkey_KeyNotRegistered, key);
90+
Logger.Debug(RubberduckUI.CommonHotkey_KeyNotRegistered, key);
9191
}
9292

9393
HotkeyInfo = new HotkeyInfo(hookId, Combo);
9494
IsAttached = true;
95-
96-
_logger.Debug("Hotkey '{0}' hooked successfully to command '{1}'", Key, Command.GetType()); //no translation needed for Debug.Writeline
9795
}
9896

9997
private void SetCommandShortcutText()

RetailCoder.VBE/Common/RubberduckHooks.cs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public class RubberduckHooks : IRubberduckHooks
2929
private readonly IEnumerable<ICommand> _commands;
3030
private readonly IList<IAttachable> _hooks = new List<IAttachable>();
3131
private readonly IDictionary<RubberduckHotkey, ICommand> _mappings;
32-
private static readonly Logger _logger = LogManager.GetCurrentClassLogger();
32+
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
3333

3434
public RubberduckHooks(VBE vbe, IGeneralConfigService config, IEnumerable<ICommand> commands)
3535
{
@@ -160,7 +160,7 @@ public void Attach()
160160
}
161161
catch (Win32Exception exception)
162162
{
163-
_logger.Error(exception);
163+
Logger.Error(exception);
164164
}
165165
}
166166

@@ -181,7 +181,7 @@ public void Detach()
181181
}
182182
catch (Win32Exception exception)
183183
{
184-
_logger.Error(exception);
184+
Logger.Error(exception);
185185
}
186186
IsAttached = false;
187187
}
@@ -197,12 +197,10 @@ private void hook_MessageReceived(object sender, HookEventArgs e)
197197
var hotkey = sender as IHotkey;
198198
if (hotkey != null)
199199
{
200-
_logger.Debug("Hotkey message received");
201200
hotkey.Command.Execute(null);
202201
return;
203202
}
204-
205-
_logger.Debug("Unknown message received");
203+
206204
OnMessageReceived(sender, e);
207205
}
208206

@@ -227,7 +225,7 @@ private IntPtr WindowProc(IntPtr hWnd, uint uMsg, IntPtr wParam, IntPtr lParam)
227225
}
228226
catch (Exception exception)
229227
{
230-
_logger.Error(exception);
228+
Logger.Error(exception);
231229
}
232230

233231
return IntPtr.Zero;
@@ -250,7 +248,7 @@ private bool HandleHotkeyMessage(IntPtr wParam)
250248
}
251249
catch (Exception exception)
252250
{
253-
_logger.Error(exception);
251+
Logger.Error(exception);
254252
}
255253
return processed;
256254
}

RetailCoder.VBE/Common/WinAPI/RawInput.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ public class RawInput : NativeWindow
1111
{
1212
static readonly Guid DeviceInterfaceHid = new Guid("4D1E55B2-F16F-11CF-88CB-001111000030");
1313
private readonly List<IRawDevice> _devices;
14-
private static readonly Logger _logger = LogManager.GetCurrentClassLogger();
14+
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
1515

1616
public RawInput(IntPtr parentHandle)
1717
{
@@ -47,7 +47,7 @@ protected override void WndProc(ref Message message)
4747
if (dwSize != res)
4848
{
4949
var ex = new Win32Exception(Marshal.GetLastWin32Error());
50-
_logger.Error(ex, "Error getting the rawinput buffer: {0}", ex.Message);
50+
Logger.Error(ex, "Error getting the rawinput buffer: {0}", ex.Message);
5151
return;
5252
}
5353
foreach (var device in _devices)

RetailCoder.VBE/Refactorings/ExtractInterface/ExtractInterfaceRefactoring.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public class ExtractInterfaceRefactoring : IRefactoring
1919
private readonly IMessageBox _messageBox;
2020
private readonly IRefactoringPresenterFactory<ExtractInterfacePresenter> _factory;
2121
private ExtractInterfaceModel _model;
22-
private static readonly Logger _logger = LogManager.GetCurrentClassLogger();
22+
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
2323

2424
public ExtractInterfaceRefactoring(VBE vbe, RubberduckParserState state, IMessageBox messageBox, IRefactoringPresenterFactory<ExtractInterfacePresenter> factory)
2525
{
@@ -81,13 +81,11 @@ private void AddInterface()
8181
private int _insertionLine;
8282
private void _state_StateChanged(object sender, EventArgs e)
8383
{
84-
_logger.Debug("ExtractInterfaceRefactoring handles StateChanged...");
8584
if (_state.Status != ParserState.Ready)
8685
{
8786
return;
8887
}
89-
90-
_logger.Debug("Implementing extracted interface...");
88+
9189
var qualifiedSelection = new QualifiedSelection(_model.TargetDeclaration.QualifiedSelection.QualifiedName, new Selection(_insertionLine, 1, _insertionLine, 1));
9290
_vbe.ActiveCodePane.CodeModule.SetSelection(qualifiedSelection);
9391

RetailCoder.VBE/Root/RubberduckModule.cs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,6 @@ public class RubberduckModule : NinjectModule
4949
private const int MsForms = 17;
5050
private const int MsFormsControl = 18;
5151

52-
private static readonly Logger _logger = LogManager.GetCurrentClassLogger();
53-
5452
public RubberduckModule(VBE vbe, AddIn addin)
5553
{
5654
_vbe = vbe;
@@ -59,8 +57,6 @@ public RubberduckModule(VBE vbe, AddIn addin)
5957

6058
public override void Load()
6159
{
62-
_logger.Debug("in RubberduckModule.Load()");
63-
6460
// bind VBE and AddIn dependencies to host-provided instances.
6561
Bind<VBE>().ToConstant(_vbe);
6662
Bind<AddIn>().ToConstant(_addin);
@@ -149,7 +145,6 @@ public override void Load()
149145
ConfigureProjectExplorerContextMenu();
150146

151147
BindWindowsHooks();
152-
_logger.Debug("completed RubberduckModule.Load()");
153148
}
154149

155150
private void BindWindowsHooks()

RetailCoder.VBE/UI/Command/MenuItems/ParentMenus/ParentMenuItemBase.cs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public abstract class ParentMenuItemBase : IParentMenuItem
1717
private readonly string _key;
1818
private readonly int? _beforeIndex;
1919
private readonly IDictionary<IMenuItem, CommandBarControl> _items;
20-
private static readonly Logger _logger = LogManager.GetCurrentClassLogger();
20+
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
2121

2222
protected ParentMenuItemBase(string key, IEnumerable<IMenuItem> items, int? beforeIndex = null)
2323
{
@@ -78,8 +78,6 @@ public void Initialize()
7878
_items[item] = InitializeChildControl(item as ICommandMenuItem)
7979
?? InitializeChildControl(item as IParentMenuItem);
8080
}
81-
82-
_logger.Debug("'{0}' ({1}) parent menu initialized, hash code {2}.", _key, GetHashCode(), Item.GetHashCode());
8381
}
8482

8583
public void RemoveChildren()
@@ -144,9 +142,7 @@ private CommandBarControl InitializeChildControl(ICommandMenuItem item)
144142
var command = item.Command as CommandBase; // todo: add 'ShortcutText' to a new 'interface ICommand : System.Windows.Input.ICommand'
145143
child.ShortcutText = command != null
146144
? command.ShortcutText
147-
: string.Empty;
148-
149-
_logger.Debug("Menu item '{0}' created; hash code: {1} (command hash code {2})", child.Caption, child.GetHashCode(), item.Command.GetHashCode());
145+
: string.Empty;
150146

151147
child.Click += child_Click;
152148
return child;
@@ -167,7 +163,7 @@ private void child_Click(CommandBarButton Ctrl, ref bool CancelDefault)
167163
// hash code is different on every frakkin' click. go figure. I've had it, this is the fix.
168164
_lastHashCode = Ctrl.GetHashCode();
169165

170-
_logger.Debug("({0}) Executing click handler for menu item '{1}', hash code {2}", GetHashCode(), Ctrl.Caption, Ctrl.GetHashCode());
166+
Logger.Debug("({0}) Executing click handler for menu item '{1}', hash code {2}", GetHashCode(), Ctrl.Caption, Ctrl.GetHashCode());
171167
item.Command.Execute(null);
172168
}
173169

@@ -189,7 +185,7 @@ public static void SetButtonImage(CommandBarButton button, Image image, Image ma
189185
}
190186
catch (COMException exception)
191187
{
192-
_logger.Debug("Button image could not be set for button [" + button.Caption + "]\n" + exception);
188+
Logger.Debug("Button image could not be set for button [" + button.Caption + "]\n" + exception);
193189
}
194190
}
195191

0 commit comments

Comments
 (0)