Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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 join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant