From 4433b67c829cb3510ba5b409b20760fff8779499 Mon Sep 17 00:00:00 2001 From: Athanasius Date: Fri, 13 Aug 2021 15:06:35 +0100 Subject: [PATCH] EDMarketConnector: Use `logger.trace_if(...)` Yes, leaving that 'truncating plain logfile' as plain trace. --- Contributing.md | 9 +++++++-- EDMarketConnector.py | 8 ++++---- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/Contributing.md b/Contributing.md index 814ff7ca..c74953a1 100644 --- a/Contributing.md +++ b/Contributing.md @@ -416,13 +416,18 @@ In addition to that we utilise one of the user-defined levels as: method provided on `logger`: ```python - logger.trace_if('my-trace-rule', 'my-log-message') + logger.trace_if('journal.event.scan', 'my-log-message') ``` + The string used to identify this tracing should be related to the + **function of the code**, not the particular file, or class, that it is in. + This is so that the same string can be used to trace code that spans more + than one file, class, or other scope. + This would then be triggered by running EDMarketConnector with the appropriate command-line arguments: - EDMarketConnector.py --trace-on my-trace-rule + EDMarketConnector.py --trace-on journal.event.scan Note that you do **not** also need to specify `--trace`, that's implied. diff --git a/EDMarketConnector.py b/EDMarketConnector.py index b2d4cba8..a44a465d 100755 --- a/EDMarketConnector.py +++ b/EDMarketConnector.py @@ -174,7 +174,7 @@ if __name__ == '__main__': # noqa: C901 def handle_edmc_callback_or_foregrounding() -> None: # noqa: CCR001 """Handle any edmc:// auth callback, else foreground existing window.""" - logger.trace('Begin...') + logger.trace_if('frontier-auth.windows', 'Begin...') if platform == 'win32': @@ -1108,7 +1108,7 @@ class AppWindow(object): entry = monitor.get_entry() if not entry: # This is expected due to some monitor.py code that appends `None` - # logger.trace('No entry from monitor.get_entry()') + logger.trace_if('journal.queue', 'No entry from monitor.get_entry()') return # Update main window @@ -1199,7 +1199,7 @@ class AppWindow(object): return # in CQC if not entry['event'] or not monitor.mode: - # logger.trace('Startup, returning') + logger.trace_if('journal.queue', 'Startup, returning') return # Startup if entry['event'] in ['StartUp', 'LoadGame'] and monitor.started: @@ -1828,7 +1828,7 @@ sys.path: {sys.path}''' ui_scale = 100 config.set('ui_scale', ui_scale) theme.default_ui_scale = root.tk.call('tk', 'scaling') - logger.trace(f'Default tk scaling = {theme.default_ui_scale}') + logger.trace_if('tk', f'Default tk scaling = {theme.default_ui_scale}') theme.startup_ui_scale = ui_scale root.tk.call('tk', 'scaling', theme.default_ui_scale * float(ui_scale) / 100.0) app = AppWindow(root)