Skip to content

Conversation

@choppsv1
Copy link
Collaborator

@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 choppsv1 force-pushed the chopps/templog+test branch 2 times, most recently from 31ed836 to 903661a Compare July 7, 2025 06:28
libyang/log.py Outdated
Comment on lines 34 to 35
_ffi = cffi.FFI()
opts = _ffi.new("uint32_t *", opt)
Copy link
Collaborator

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)

Copy link
Collaborator Author

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.

Comment on lines 1 to 7
# -*- 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.
#
Copy link
Collaborator

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?

Copy link
Collaborator Author

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]>
@choppsv1 choppsv1 force-pushed the chopps/templog+test branch from 903661a to 4211c19 Compare November 11, 2025 14:15
@choppsv1
Copy link
Collaborator Author

@rjarry could we get this one and the other API #154 merged in and then cut a new release, before the transition to 4?

@rjarry rjarry merged commit 1deecd8 into CESNET:master Nov 12, 2025
10 checks passed
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.

2 participants