1#pylint: disable-msg=C0111
2import common
3import logging, os
4from autotest_lib.client.common_lib import logging_config
5
6class ServerLoggingConfig(logging_config.LoggingConfig):
7    def add_debug_file_handlers(self, log_dir, log_name=None):
8        if not log_name:
9            log_name = 'autoserv'
10        self._add_file_handlers_for_all_levels(log_dir, log_name)
11
12
13    def configure_logging(self, results_dir=None, use_console=True,
14                          verbose=False, no_console_prefix=False,
15                          debug_log_name=None):
16        if no_console_prefix:
17            self.console_formatter = logging.Formatter()
18
19        super(ServerLoggingConfig, self).configure_logging(use_console, verbose)
20
21        if results_dir:
22            log_dir = os.path.join(results_dir, 'debug')
23            if not os.path.exists(log_dir):
24                os.mkdir(log_dir)
25            self.add_debug_file_handlers(log_dir, log_name=debug_log_name)
26