示例#1
0
 def test_init(self, log_n, log_s):
     """ Test log system creation. """
     print("running log setup for %s" % (log_n,))
     extra = dict()
     if log_n == "file":
         extra = {
             "handler_options": {
                 "filename": os.path.join(TEST_DIR, "file.log"),
             }
         }
     log.setup_log("foo", log_n, extra=extra)
     print("...test log setup ok")
示例#2
0
    def _initialize_log(self, stdout=False):
        """
        Initialize the log system.

        If stdout is set to True then the log is initialized to print
        to stdout independently from the configuration.
        """
        log_level = self._config.get("loglevel", "warning")
        if stdout:
            log.setup_log(self.prog, "stdout", log_level)
            log.setup_log("pika", "stdout", log_level)
        else:
            log_type = self._config.get("log", "stdout")
            handler_options = dict()
            if log_type == "file":
                if "logfile" not in self._config:
                    raise AttributeError(
                        "logfile required for file log system")
                handler_options['filename'] = self._config["logfile"]
            extra = {
                'handler_options': handler_options,
            }
            log.setup_log(self.prog, log_type, log_level, extra)
            log.setup_log("pika", log_type, log_level, extra)
        self.logger = logging.getLogger(self.prog)
        mtb.pid.LOGGER = logging.getLogger(self.prog)
示例#3
0
    def _initialize_log(self, stdout=False):
        """
        Initialize the log system.

        If stdout is set to True then the log is initialized to print
        to stdout independently from the configuration.
        """
        log_level = self._config.get("loglevel", "warning")
        if stdout:
            log.setup_log(self.prog, "stdout", log_level)
            log.setup_log("pika", "stdout", log_level)
        else:
            log_type = self._config.get("log", "stdout")
            handler_options = dict()
            if log_type == "file":
                if "logfile" not in self._config:
                    raise AttributeError(
                        "logfile required for file log system")
                handler_options['filename'] = self._config["logfile"]
            extra = {
                'handler_options': handler_options,
            }
            log.setup_log(self.prog, log_type, log_level, extra)
            log.setup_log("pika", log_type, log_level, extra)
        self.logger = logging.getLogger(self.prog)
        mtb.pid.LOGGER = logging.getLogger(self.prog)
示例#4
0
 def test_log_operations(self, log_n, log_s):
     """ Test log system operations. """
     print("running log operations checking for %s" % (log_n,))
     extra = dict()
     if log_n == "file":
         extra = {
             "handler_options": {
                 "filename": os.path.join(TEST_DIR, "file.log"),
             }
         }
     log.setup_log("foo", log_n, extra=extra)
     logger = logging.getLogger("foo")
     for operation in LOG_OPERATIONS:
         getattr(logger, operation)(
             "log test for %s.%s" % (log_n, operation))
     print("...test log operations checking ok")