-
Notifications
You must be signed in to change notification settings - Fork 53
Fix logging bug, add access to temp_log_options(), and add logging tests. #142
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
Conversation
31ed836 to
903661a
Compare
libyang/log.py
Outdated
| _ffi = cffi.FFI() | ||
| opts = _ffi.new("uint32_t *", opt) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You already have an ffi object available and imported, use it instead of creating a new one.
opts = ffi.new("uint32_t *", opt)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not sure why I did that, anyway, fixed.
tests/test_log.py
Outdated
| # -*- coding: utf-8 eval: (blacken-mode 1) -*- | ||
| # SPDX-License-Identifier: MIT | ||
| # | ||
| # July 7 2025, Christian Hopps <[email protected]> | ||
| # | ||
| # Copyright (c) 2025, LabN Consulting, L.L.C. | ||
| # |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you follow the same license header than in all files please?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
The arg is added as `str` but the fmt requires `int`, causes exception when turning on python logging -- fix. Signed-off-by: Christian Hopps <[email protected]>
When one wishes to disable logging temporarily (e.g., when calling API functions
when an error result is expected and OK), libyang provides
ly_temp_log_options(). We need access to this in python, so export access to the
function and add a python context (i.e., "with") manager API for using
it idiomatically as well.
ex usage:
```
with temp_log_options(0):
ly_unwanted_logging_call();
```
Signed-off-by: Christian Hopps <[email protected]>
Add a new log unit test. Add a test for the newly exposed temp_log_options() function as well as the already implemented configure_logging() function. Signed-off-by: Christian Hopps <[email protected]>
903661a to
4211c19
Compare
Fix bug with logging - the line arg is added as
strbut the fmt requiresint, which causes exception when turning on python logging -- fixed.Add temp_log_options() API access - when one wishes to disable logging temporarily (e.g., when calling API functions when an error result is expected and OK), libyang provides ly_temp_log_options() -- add access to the function:
ex usage: