Skip to content

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
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)

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?

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