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

logger: add logLevel to DSCI devFlags #1307

Merged

Commits on Oct 21, 2024

  1. logger: add logLevel to DSCI devFlags

    Jira: https://issues.redhat.com/browse/RHOAIENG-14713
    
    This is a squashed commit of the patchset (original ids):
    
    959f84d ("logger: import controller-runtime zap as ctrlzap")
    b8d9cde ("logger: add logLevel to DSCI devFlags")
    2d3efe2 ("components, logger: always use controller's logger")
    1ef9266 ("components, logger: use one function for ctx creation")
    
    - logger: import controller-runtime zap as ctrlzap
    
    To avoid patch polluting with the next changes where uber's zap is
    imported as `zap`.
    
    - logger: add logLevel to DSCI devFlags
    
    Allow to override global zap log level from DSCI devFlags. Accepts
    the same values as to `--zap-log-level` command line switch.
    
    Use zap.AtomicLevel type to store loglevel. Locally use atomic to
    store its value. We must store the structure itsel since command
    line flags parser (ctrlzap.(*levelFlag).Set()) stores the structure
    there. In its order ctrlzap.addDefault() stores pointers,
    newOptions() always sets the level to avoid setting it by
    addDefaults(). Otherwise SetLevel should handle both pointer and the
    structure as logLevel atomic.Value.
    
    It is ok to store structure of zap.AtomicLevel since it itself
    contains a pointer to the atomic.Int32 and common level value is
    changed then.
    
    The parsing code is modified version of the one from
    controller-runtime/pkg/log/zap/flag.go.
    
    Deprecate DSCI.DevFlags.logmode.
    
    - components, logger: always use controller's logger
    
    Since the log level is overridable with its own field of devFlags,
    do not use logmode anymore. It was used to create own logger with
    own zap backend in case if devFlags exist.
    
    Just add name and value to the existing logger instead.
    
    Rename NewLoggerWithOptions back to NewLogger since former NewLogger
    is removed.
    
    Change component logger name. "DSC.Component" is redundant. It was
    usuful when component's logger was created from scratch, but now
    when it is always based on the reconciler's one, it's clear that it
    is a part of DSC.
    
    - components, logger: use one function for ctx creation
    
    Move both logger and component creation to one function.
    
    Just a cleanup.
    
    Signed-off-by: Yauheni Kaliuta <ykaliuta@redhat.com>
    ykaliuta committed Oct 21, 2024
    Configuration menu
    Copy the full SHA
    a9be965 View commit details
    Browse the repository at this point in the history