Exemplo n.º 1
0
 def provide_logger(self) -> Logger:
     """innit logger"""
     logger = get_logger(
         logger_name='SitesCheckerService',
         logger_format=LoggingFormat.JSON,
         logger_level=logging.INFO,
         logger_output=LoggingOutput.STDOUT,
     )
     return logger
    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,
                logger_output=self.logger_output
            )

        return self.__logger
Exemplo n.º 3
0
    def __init__(self, kv):
        """Initialize
        """
        self.worker_queue = queue.Queue()
        self.verbose = kv.get("verbose", False)
        self.task = kv.get("task", None)
        self.api_key = kv.get("api-key", None)
        self.start_datetime = kv.get("start-datetime", None)
        self.end_datetime = kv.get("end-datetime", None)
        self.stocks = kv.get("stocks", None)

        assert self.api_key
        assert self.start_datetime
        assert self.end_datetime
        assert self.stocks

        self.cache = CacheClient(cache_name="stock-investor")

        self.run_start_time = dt.datetime.now()

        logger_level, logger_format, logger_output = (
            logging.INFO, LoggingFormat.JSON, LoggingOutput.STDOUT_COLOR)
        if self.verbose:
            logger_level = logging.DEBUG

        self.logger_level = logger_level
        self.logger_format = logger_format
        self.logger_output = logger_output

        self.logger = get_logger(logger_name=self.__NAME,
                                 logger_version=self.__VERSION,
                                 logger_format=self.logger_format,
                                 logger_level=self.logger_level,
                                 logger_output=self.logger_output)

        self.worker_queue_populate()
        self.__stocks_data = {}
        for stock in self.stocks:
            self.__stocks_data[stock] = {"columns": None, "data": []}
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# @namespace pyfortified_logging

from pprintpp import pprint
import logging
from pyfortified_logging 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())
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# @namespace pyfortified_logging

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

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

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("Logger file path: {0}".format(log.logger_path))

logger_fp = open(log.logger_path, 'r')
pprint(logger_fp.readlines())

pprint(log.getLevelName())
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# @namespace pyfortified_logging

import logging
from pprintpp import pprint
from pyfortified_logging 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())