示例#1
0
    def logger(self):
        """Get Property: Logger
        """
        if self.__logger is None:
            self.__logger = get_logger(logger_name=__name__.split('.')[0],
                                       logger_version=__version__,
                                       logger_format=self.logger_format,
                                       logger_level=self.logger_level)

        return self.__logger
    def test_logging_file(self):
        log = get_logger(logger_name=__name__,
                         logger_version=__version__,
                         logger_level=logging.DEBUG,
                         logger_output=LoggingOutput.FILE)

        assert (log is not None)
        assert (os.path.exists(log.logger_path) is True)

        log.info("logging: info", extra={'test': __name__})
        log.debug("logging: debug", extra={'test': __name__})
        log.warning("logging: warning", extra={'test': __name__})
        log.error("logging: error", extra={'test': __name__})
        log.critical("logging: critical", extra={'test': __name__})
        log.exception("logging: exception", extra={'test': __name__})

        assert (log.logger_path)
        logger_fp = open(log.logger_path, 'r')
        assert (logger_fp)
        assert (logger_fp.readlines())
    def test_logging_buffer(self):
        buffer = io.StringIO()
        logger_handler = logging.StreamHandler(buffer)

        log = get_logger(logger_name=__name__,
                         logger_version=__version__,
                         logger_level=logging.DEBUG,
                         logger_output=LoggingOutput.STDOUT,
                         logger_handler=logger_handler)

        assert (log is not None)

        log.info("logging: info", extra={'test': __name__})
        log.debug("logging: debug", extra={'test': __name__})
        log.warning("logging: warning", extra={'test': __name__})
        log.error("logging: error", extra={'test': __name__})
        log.critical("logging: critical", extra={'test': __name__})
        log.exception("logging: exception", extra={'test': __name__})

        assert (buffer.getvalue() is not None)
        buffer.close()
示例#4
0
# -*- coding: utf-8 -*-
#  @copyright 2018 TUNE, Inc. (http://www.tune.com)
#  @namespace logging_mv_integrations

from pprintpp import pprint
import logging
from logging_mv_integrations import (
    LoggingFormat,
    LoggingOutput,
    get_logger,
    __version__
)

log = get_logger(
    logger_name=__name__,
    logger_version=__version__,
    logger_level=logging.NOTE,
    logger_format=LoggingFormat.JSON,
    logger_output=LoggingOutput.STDOUT
)

log.info("logging: info", extra={'test': __name__})
log.debug("logging: debug", extra={'test': __name__})
log.note("logging: note", extra={'test': __name__})
log.warning("logging: warning", extra={'test': __name__})
log.error("logging: error", extra={'test': __name__})
log.critical("logging: critical", extra={'test': __name__})
log.exception("logging: exception", extra={'test': __name__})

pprint(log.getLevelName())
import logging
from logging_mv_integrations import (
    LoggingFormat,
    LoggingOutput,
    get_logger,
    __version__
)
from pprintpp import pprint

buffer = io.StringIO()
logger_handler = logging.StreamHandler(buffer)

log = get_logger(
    logger_name=__name__,
    logger_version=__version__,
    logger_level=logging.NOTE,
    logger_output=LoggingOutput.STDOUT,
    logger_format=LoggingFormat.STANDARD,
    logger_handler=logger_handler
)

log.info("logging: info", extra={'test': __name__})
log.note("logging: note", extra={'test': __name__})
log.debug("logging: debug", extra={'test': __name__})
log.warning("logging: warning", extra={'test': __name__})
log.error("logging: error", extra={'test': __name__})
log.critical("logging: critical", extra={'test': __name__})
log.exception("logging: exception", extra={'test': __name__})

buffer_str = buffer.getvalue()
buffer_lines = buffer_str.splitlines()
pprint(buffer_lines)
示例#6
0
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#  @copyright 2018 TUNE, Inc. (http://www.tune.com)
#  @namespace logging_mv_integrations

import logging
from pprintpp import pprint
from logging_mv_integrations import (LoggingOutput, get_logger, __version__)

log = get_logger(logger_name=__name__,
                 logger_version=__version__,
                 logger_level=logging.NOTE,
                 logger_output=LoggingOutput.STDOUT_COLOR)

log.info("logging: info", extra={'test': __name__})
log.note("logging: note", extra={'test': __name__})
log.debug("logging: debug", extra={'test': __name__})
log.warning("logging: warning", extra={'test': __name__})
log.error("logging: error", extra={'test': __name__})
log.critical("logging: critical", extra={'test': __name__})
log.exception("logging: exception", extra={'test': __name__})

pprint(log.getLevelName())
import logging
from logging_mv_integrations import (get_logger, TuneLoggingFormat,
                                     __version__)

tune_logger = get_logger(module_name=__name__,
                         logger_version=__version__,
                         logger_format=TuneLoggingFormat.STANDARD,
                         logger_level=logging.DEBUG)

tune_logger.info("logging: info", extra={'test': __name__})
tune_logger.debug("logging: debug", extra={'test': __name__})
tune_logger.warning("logging: warning", extra={'test': __name__})
tune_logger.error("logging: error", extra={'test': __name__})
tune_logger.critical("logging: critical", extra={'test': __name__})
tune_logger.exception("logging: exception", extra={'test': __name__})