Skip to content
This repository has been archived by the owner on Sep 12, 2024. It is now read-only.

Feature Request: Use native logging method so the line number of the error is shown #787

Open
sbonds opened this issue Mar 29, 2021 · 0 comments

Comments

@sbonds
Copy link

sbonds commented Mar 29, 2021

When diagnosing errors in this module, troubleshooting is often frustrated by the fact that every log message has the same line number. For example:

2021/03/29 21:39:04: INFO: /opt/microsoft/omsconfig/Scripts/3.x/Scripts/nxOMSAutomationWorker.py(844):
Test_Marshall returned [-1]: worker manager isn't running or is not latest
2021/03/29 21:39:04: INFO: /opt/microsoft/omsconfig/Scripts/3.x/Scripts/nxOMSAutomationWorker.py(844):
nxautomation was found on the system
2021/03/29 21:39:04: DEBUG: /opt/microsoft/omsconfig/Scripts/3.x/Scripts/nxOMSAutomationWorker.py(844):
No old worker process to terminate
2021/03/29 21:39:04: DEBUG: /opt/microsoft/omsconfig/Scripts/3.x/Scripts/nxOMSAutomationWorker.py(844):
Killing the instance of worker manager already running 
2021/03/29 21:39:04: DEBUG: /opt/microsoft/omsconfig/Scripts/3.x/Scripts/nxOMSAutomationWorker.py(844):
No process to terminate

Every message shows line 844, which, unsurprisingly, is the line number of the python function which wraps around the native logging function:

LG().Log(logging.getLevelName(level), message)

In some scripts, the native function is called directly allowing logs like this:

2021/03/29 19:40:02: DEBUG: /opt/microsoft/omsconfig/Scripts/3.x/Scripts/nxPackage.py(236):
PackageGroup value is False

In the above log message from nxPackage.py you can see that the Log() function is called directly so we get a useful line number (236):

LG().Log('DEBUG', 'PackageGroup value is ' + repr(PackageGroup))

As a feature request to preserve the useful line number data, I suggest calling the python Log() function directly or finding another way to preserve this important info in the logged message.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant