# This file was automatically generated by SWIG (https://www.swig.org).
# Version 4.5.1
#
# Do not make changes to this file unless you know what you are doing - modify
# the SWIG interface file instead.

import typing
# Import the low-level C/C++ module
if getattr(globals().get("__spec__"), "parent", None) or __package__ or "." in __name__:
    from . import _logger
else:
    import _logger

import builtins as __builtin__

def _swig_repr(self):
    try:
        strthis = "proxy of " + self.this.__repr__()
    except __builtin__.Exception:
        strthis = ""
    return "<%s.%s; %s >" % (self.__class__.__module__, self.__class__.__name__, strthis,)


def _swig_setattr_nondynamic_instance_variable(set):
    def set_instance_attr(self, name, value):
        if name == "this":
            set(self, name, value)
        elif name == "thisown":
            self.this.own(value)
        elif hasattr(self, name) and isinstance(getattr(type(self), name), property):
            set(self, name, value)
        else:
            raise AttributeError("You cannot add instance attributes to %s" % self)
    return set_instance_attr


def _swig_setattr_nondynamic_class_variable(set):
    def set_class_attr(cls, name, value):
        if hasattr(cls, name) and not isinstance(getattr(cls, name), property):
            set(cls, name, value)
        else:
            raise AttributeError("You cannot add class attributes to %s" % cls)
    return set_class_attr


class _SwigNonDynamicMeta(type):
    """Meta class to enforce nondynamic attributes (no new attributes) for a class"""
    __setattr__ = _swig_setattr_nondynamic_class_variable(type.__setattr__)


import weakref

from . import common
from . import exception
class LoggerUniquePtr(object):
    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
    __repr__ = _swig_repr

    def __init__(self, *args):
        _logger.LoggerUniquePtr_swiginit(self, _logger.new_LoggerUniquePtr(*args))

    def __deref__(self):
        return _logger.LoggerUniquePtr___deref__(self)

    def release(self):
        return _logger.LoggerUniquePtr_release(self)

    def reset(self, __p=None):
        return _logger.LoggerUniquePtr_reset(self, __p)

    def swap(self, __u):
        return _logger.LoggerUniquePtr_swap(self, __u)

    def get(self):
        return _logger.LoggerUniquePtr_get(self)

    def __bool__(self):
        return _logger.LoggerUniquePtr___bool__(self)


    __swig_destroy__ = _logger.delete_LoggerUniquePtr

    def level_to_cstr(self, level):
        return _logger.LoggerUniquePtr_level_to_cstr(self, level)

    def log_line(self, level, message):
        return _logger.LoggerUniquePtr_log_line(self, level, message)

    def write(self, time, pid, level, message):
        return _logger.LoggerUniquePtr_write(self, time, pid, level, message)

    def critical(self, msg):
        return _logger.LoggerUniquePtr_critical(self, msg)

    def error(self, msg):
        return _logger.LoggerUniquePtr_error(self, msg)

    def warning(self, msg):
        return _logger.LoggerUniquePtr_warning(self, msg)

    def notice(self, msg):
        return _logger.LoggerUniquePtr_notice(self, msg)

    def info(self, msg):
        return _logger.LoggerUniquePtr_info(self, msg)

    def debug(self, msg):
        return _logger.LoggerUniquePtr_debug(self, msg)

    def trace(self, msg):
        return _logger.LoggerUniquePtr_trace(self, msg)

    def log(self, level, msg):
        return _logger.LoggerUniquePtr_log(self, level, msg)

# Register LoggerUniquePtr in _logger:
_logger.LoggerUniquePtr_swigregister(LoggerUniquePtr)
class MemoryBufferLoggerUniquePtr(object):
    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
    __repr__ = _swig_repr

    def __init__(self, *args):
        _logger.MemoryBufferLoggerUniquePtr_swiginit(self, _logger.new_MemoryBufferLoggerUniquePtr(*args))

    def __deref__(self):
        return _logger.MemoryBufferLoggerUniquePtr___deref__(self)

    def release(self):
        return _logger.MemoryBufferLoggerUniquePtr_release(self)

    def reset(self, __p=None):
        return _logger.MemoryBufferLoggerUniquePtr_reset(self, __p)

    def swap(self, __u):
        return _logger.MemoryBufferLoggerUniquePtr_swap(self, __u)

    def get(self):
        return _logger.MemoryBufferLoggerUniquePtr_get(self)

    def __bool__(self):
        return _logger.MemoryBufferLoggerUniquePtr___bool__(self)


    __swig_destroy__ = _logger.delete_MemoryBufferLoggerUniquePtr

    def write(self, time, pid, level, message):
        return _logger.MemoryBufferLoggerUniquePtr_write(self, time, pid, level, message)

    def get_items_count(self):
        return _logger.MemoryBufferLoggerUniquePtr_get_items_count(self)

    def get_item(self, item_idx):
        return _logger.MemoryBufferLoggerUniquePtr_get_item(self, item_idx)

    def clear(self):
        return _logger.MemoryBufferLoggerUniquePtr_clear(self)

    def write_to_logger(self, logger):
        return _logger.MemoryBufferLoggerUniquePtr_write_to_logger(self, logger)

    def level_to_cstr(self, level):
        return _logger.MemoryBufferLoggerUniquePtr_level_to_cstr(self, level)

    def log_line(self, level, message):
        return _logger.MemoryBufferLoggerUniquePtr_log_line(self, level, message)

    def critical(self, msg):
        return _logger.MemoryBufferLoggerUniquePtr_critical(self, msg)

    def error(self, msg):
        return _logger.MemoryBufferLoggerUniquePtr_error(self, msg)

    def warning(self, msg):
        return _logger.MemoryBufferLoggerUniquePtr_warning(self, msg)

    def notice(self, msg):
        return _logger.MemoryBufferLoggerUniquePtr_notice(self, msg)

    def info(self, msg):
        return _logger.MemoryBufferLoggerUniquePtr_info(self, msg)

    def debug(self, msg):
        return _logger.MemoryBufferLoggerUniquePtr_debug(self, msg)

    def trace(self, msg):
        return _logger.MemoryBufferLoggerUniquePtr_trace(self, msg)

    def log(self, level, msg):
        return _logger.MemoryBufferLoggerUniquePtr_log(self, level, msg)

# Register MemoryBufferLoggerUniquePtr in _logger:
_logger.MemoryBufferLoggerUniquePtr_swigregister(MemoryBufferLoggerUniquePtr)
class LogRouterWeakPtr(object):
    r"""
    WeakPtr is a "smart" pointer. It contains a pointer to resource and to guard of resource.
    WeakPtr pointer can be owner of the resource. However, the resource itself may depend on another resource.
    WeakPtr registers/unregisters itself at the guard of resource. And the resource guard invalidates
    the registered WeakPtrs when the resource is unusable (eg. its dependecny was released).
    Note on thread safety:
    It is safe to create, access and destroy WeakPtrs in multiple threads simultaneously.
    """

    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
    __repr__ = _swig_repr

    def __init__(self, *args):
        _logger.LogRouterWeakPtr_swiginit(self, _logger.new_LogRouterWeakPtr(*args))
    __swig_destroy__ = _logger.delete_LogRouterWeakPtr

    def __deref__(self):
        r"""Provides access to the managed object. Generates exception if object is not valid."""
        return _logger.LogRouterWeakPtr___deref__(self)

    def get(self):
        r"""Returns a pointer to the managed object. Generates exception if object is not valid."""
        return _logger.LogRouterWeakPtr_get(self)

    def is_valid(self):
        r"""Checks if managed object is valid."""
        return _logger.LogRouterWeakPtr_is_valid(self)

    def has_same_guard(self, other):
        r"""Checks if the other WeakPtr instance has the same WeakPtrGuard."""
        return _logger.LogRouterWeakPtr_has_same_guard(self, other)

    def __ref__(self):
        return _logger.LogRouterWeakPtr___ref__(self)

    def __eq__(self, other):
        return _logger.LogRouterWeakPtr___eq__(self, other)

    def __ne__(self, other):
        return _logger.LogRouterWeakPtr___ne__(self, other)

    def __lt__(self, other):
        return _logger.LogRouterWeakPtr___lt__(self, other)

    def __gt__(self, other):
        return _logger.LogRouterWeakPtr___gt__(self, other)

    def __le__(self, other):
        return _logger.LogRouterWeakPtr___le__(self, other)

    def __ge__(self, other):
        return _logger.LogRouterWeakPtr___ge__(self, other)

    def __hash__(self):
        return _logger.LogRouterWeakPtr___hash__(self)

    def add_logger(self, logger):
        r"""Moves (registers) the "logger" into the log router. It gets next free index number."""
        return _logger.LogRouterWeakPtr_add_logger(self, logger)

    def get_logger(self, index):
        r"""Returns pointer to the logger at the "index" position."""
        return _logger.LogRouterWeakPtr_get_logger(self, index)

    def release_logger(self, index):
        r"""
        Removes logger at the "index" position from LogRouter.
        The array of the loggers is squeezed. Index of the loggers behind removed logger is decreased by one.
        """
        return _logger.LogRouterWeakPtr_release_logger(self, index)

    def swap_logger(self, logger, index):
        r"""Swaps the logger at the "index" position with another "logger"."""
        return _logger.LogRouterWeakPtr_swap_logger(self, logger, index)

    def get_loggers_count(self):
        r"""Returns number of loggers registered in LogRouter."""
        return _logger.LogRouterWeakPtr_get_loggers_count(self)

    def log_line(self, level, message):
        return _logger.LogRouterWeakPtr_log_line(self, level, message)

    def write(self, time, pid, level, message):
        return _logger.LogRouterWeakPtr_write(self, time, pid, level, message)

    def level_to_cstr(self, level):
        return _logger.LogRouterWeakPtr_level_to_cstr(self, level)

    def critical(self, msg):
        return _logger.LogRouterWeakPtr_critical(self, msg)

    def error(self, msg):
        return _logger.LogRouterWeakPtr_error(self, msg)

    def warning(self, msg):
        return _logger.LogRouterWeakPtr_warning(self, msg)

    def notice(self, msg):
        return _logger.LogRouterWeakPtr_notice(self, msg)

    def info(self, msg):
        return _logger.LogRouterWeakPtr_info(self, msg)

    def debug(self, msg):
        return _logger.LogRouterWeakPtr_debug(self, msg)

    def trace(self, msg):
        return _logger.LogRouterWeakPtr_trace(self, msg)

    def log(self, level, msg):
        return _logger.LogRouterWeakPtr_log(self, level, msg)

# Register LogRouterWeakPtr in _logger:
_logger.LogRouterWeakPtr_swigregister(LogRouterWeakPtr)
class Logger(object):
    r"""
    Logger is an abstract interface used for logging.
    An implementation (inherited class) can call callbacks, log the messages to memory, file, or somewhere else.
    """

    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
    __repr__ = _swig_repr

    def __init__(self):
        if self.__class__ == Logger:
            _self = None
        else:
            _self = self
        _logger.Logger_swiginit(self, _logger.new_Logger(_self, ))
    __swig_destroy__ = _logger.delete_Logger
    Level_CRITICAL = _logger.Logger_Level_CRITICAL
    Level_ERROR = _logger.Logger_Level_ERROR
    Level_WARNING = _logger.Logger_Level_WARNING
    Level_NOTICE = _logger.Logger_Level_NOTICE
    Level_INFO = _logger.Logger_Level_INFO
    Level_DEBUG = _logger.Logger_Level_DEBUG
    Level_TRACE = _logger.Logger_Level_TRACE

    @staticmethod
    def level_to_cstr(level):
        return _logger.Logger_level_to_cstr(level)

    def log_line(self, level, message):
        return _logger.Logger_log_line(self, level, message)

    def write(self, time, pid, level, message):
        return _logger.Logger_write(self, time, pid, level, message)

    def critical(self, msg):
        return _logger.Logger_critical(self, msg)

    def error(self, msg):
        return _logger.Logger_error(self, msg)

    def warning(self, msg):
        return _logger.Logger_warning(self, msg)

    def notice(self, msg):
        return _logger.Logger_notice(self, msg)

    def info(self, msg):
        return _logger.Logger_info(self, msg)

    def debug(self, msg):
        return _logger.Logger_debug(self, msg)

    def trace(self, msg):
        return _logger.Logger_trace(self, msg)

    def log(self, level, msg):
        return _logger.Logger_log(self, level, msg)
    def __disown__(self):
        self.this.disown()
        _logger.disown_Logger(self)
        return weakref.proxy(self)

# Register Logger in _logger:
_logger.Logger_swigregister(Logger)
class StringLogger(Logger):
    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")

    def __init__(self, *args, **kwargs):
        raise AttributeError("No constructor defined - class is abstract")
    __repr__ = _swig_repr
    __swig_destroy__ = _logger.delete_StringLogger

    def write(self, *args):
        return _logger.StringLogger_write(self, *args)

# Register StringLogger in _logger:
_logger.StringLogger_swigregister(StringLogger)
class LogRouter(Logger):
    r"""
    LogRouter is an implementation of logging class that forwards incoming logging messages to several other loggers.
    Loggers can be addressed via index. Index is serial number of the logger starting from zero.
    """

    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
    __repr__ = _swig_repr
    __swig_destroy__ = _logger.delete_LogRouter

    def __init__(self, *args):
        r"""
        *Overload 1:*
        Constructs a new LogRouter instance with an empty set of destination loggers.

        |

        *Overload 2:*
        Constructs a new LogRouter instance and sets the destination loggers.
        """
        _logger.LogRouter_swiginit(self, _logger.new_LogRouter(*args))

    def add_logger(self, logger):
        r"""Moves (registers) the "logger" into the log router. It gets next free index number."""
        return _logger.LogRouter_add_logger(self, logger)

    def get_logger(self, index):
        r"""Returns pointer to the logger at the "index" position."""
        return _logger.LogRouter_get_logger(self, index)

    def release_logger(self, index):
        r"""
        Removes logger at the "index" position from LogRouter.
        The array of the loggers is squeezed. Index of the loggers behind removed logger is decreased by one.
        """
        return _logger.LogRouter_release_logger(self, index)

    def swap_logger(self, logger, index):
        r"""Swaps the logger at the "index" position with another "logger"."""
        return _logger.LogRouter_swap_logger(self, logger, index)

    def get_loggers_count(self):
        r"""Returns number of loggers registered in LogRouter."""
        return _logger.LogRouter_get_loggers_count(self)

    def log_line(self, level, message):
        return _logger.LogRouter_log_line(self, level, message)

    def write(self, time, pid, level, message):
        return _logger.LogRouter_write(self, time, pid, level, message)

# Register LogRouter in _logger:
_logger.LogRouter_swigregister(LogRouter)
class GlobalLogger(object):
    r"""
    GlobalLogger contains methods for setting the target (logger) for global messages - messages that are
    generated by libraries (eg librepo) without binding to the Base object.
    """

    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
    __repr__ = _swig_repr

    def __init__(self):
        _logger.GlobalLogger_swiginit(self, _logger.new_GlobalLogger())
    __swig_destroy__ = _logger.delete_GlobalLogger

    @staticmethod
    def set(destination, verbosity):
        return _logger.GlobalLogger_set(destination, verbosity)

    @staticmethod
    def unset():
        return _logger.GlobalLogger_unset()

# Register GlobalLogger in _logger:
_logger.GlobalLogger_swigregister(GlobalLogger)
class MemoryBufferLogger(Logger):
    r"""
    MemoryBufferLogger is an implementation of logging class that stores incoming logging messages into memory buffer.
    It is usually used as temporary logger until a final logger is configured.
    """

    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
    __repr__ = _swig_repr

    def __init__(self, *args):
        _logger.MemoryBufferLogger_swiginit(self, _logger.new_MemoryBufferLogger(*args))
    __swig_destroy__ = _logger.delete_MemoryBufferLogger

    def write(self, time, pid, level, message):
        return _logger.MemoryBufferLogger_write(self, time, pid, level, message)

    def get_items_count(self):
        return _logger.MemoryBufferLogger_get_items_count(self)

    def get_item(self, item_idx):
        return _logger.MemoryBufferLogger_get_item(self, item_idx)

    def clear(self):
        return _logger.MemoryBufferLogger_clear(self)

    def write_to_logger(self, logger):
        return _logger.MemoryBufferLogger_write_to_logger(self, logger)

# Register MemoryBufferLogger in _logger:
_logger.MemoryBufferLogger_swigregister(MemoryBufferLogger)
class RotatingFileLogger(StringLogger):
    r"""
    RotatingFileLogger is an implementation of a rotating file logger.
    It can be used simultaneously in multiple processes and threads.
    """

    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
    __repr__ = _swig_repr

    def __init__(self, base_file_path, max_bytes, backup_count):
        r"""
        Construct a new instance of the `RotatingFileLogger` class.

        It immediately opens (creates) `base_file_path` to detect problems before logging starts.

        When `max_bytes` is non-zero and `backup_count` is non-zero, rotation is enabled.
        For example, with `backup_count` of 5 and a `base_file_path` of "app.log", we would get "app.log", "app.log.1",
        "app.log.2" through "app.log.5". The file written to is always "app.log". If the message being written does not
        fit into the file (the size of the resulting file would be greater than `max_bytes`), it is closed and renamed
        to "app.log.1", and if there are files "app.log.1", "app.log.2", etc., then they are renamed on "app.log.2",
        "app.log.3" etc. Writing is done to a new "app.log" file.
        Note: The message being written is not split into multiple files. -> The log file can be larger than `max_bytes`
        if the message being written is larger than `max_bytes`. The file then only contains this message.

        :type base_file_path: std::filesystem::path
        :param base_file_path: path to the file where log messages are written
        :type max_bytes: std::size_t
        :param max_bytes:      max log file size; 0 - means unlimited; at least one full message can always be written
        :type backup_count: std::size_t
        :param backup_count:   maximum number of backup files; 0 - means rotation is disabled
        """
        _logger.RotatingFileLogger_swiginit(self, _logger.new_RotatingFileLogger(base_file_path, max_bytes, backup_count))
    __swig_destroy__ = _logger.delete_RotatingFileLogger

    def write(self, *args):
        return _logger.RotatingFileLogger_write(self, *args)

# Register RotatingFileLogger in _logger:
_logger.RotatingFileLogger_swigregister(RotatingFileLogger)

def create_file_logger(base, filename):
    r"""
    Helper method for creating a file logger in `logdir` location with given file name.
    :type base: libdnf5::Base
    :param base: Reference to Base for loading the configured logger path.
    :type filename: string
    :param filename: Name of the log file.
    :rtype: std::unique_ptr< libdnf5::Logger >
    :return: Instance of a new file logger.
    """
    return _logger.create_file_logger(base, filename)

def create_rotating_file_logger(base, filename):
    r"""
    Helper method for creating a rotating file logger in `logdir` location with given file name.
    :type base: libdnf5::Base
    :param base: Reference to Base for loading the configured parameters.
    :type filename: string
    :param filename: Name of the log file.
    :rtype: std::unique_ptr< libdnf5::Logger >
    :return: Instance of a new rotating file logger.
    """
    return _logger.create_rotating_file_logger(base, filename)

