Skip to content

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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

choppsv1
Copy link
Contributor

@choppsv1 choppsv1 commented Jul 7, 2025

  • Fix bug with logging - the line arg is added as str but the fmt requires int, 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:

    with temp_log_options(0):
        ly_unwanted_logging_call();
  • Add unit test which tests both the bugfix and the new API function.

choppsv1 added 2 commits July 7, 2025 02:07
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]>
@choppsv1 choppsv1 force-pushed the chopps/templog+test branch from c35aca2 to 31ed836 Compare July 7, 2025 06:20
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]>
@choppsv1 choppsv1 force-pushed the chopps/templog+test branch from 31ed836 to 903661a Compare July 7, 2025 06:28
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

Successfully merging this pull request may close these issues.

1 participant