Aviv Keshet | e43bccf | 2013-08-14 14:11:59 -0700 | [diff] [blame] | 1 | #pylint: disable-msg=C0111 |
showard | 75cdfee | 2009-06-10 17:40:41 +0000 | [diff] [blame] | 2 | import common |
| 3 | import logging, os |
| 4 | from autotest_lib.client.common_lib import logging_config |
| 5 | |
| 6 | class 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' |
showard | f2de81b | 2009-06-15 20:23:10 +0000 | [diff] [blame] | 10 | self._add_file_handlers_for_all_levels(log_dir, log_name) |
showard | 75cdfee | 2009-06-10 17:40:41 +0000 | [diff] [blame] | 11 | |
| 12 | |
showard | 10d8417 | 2009-06-18 23:16:50 +0000 | [diff] [blame] | 13 | def configure_logging(self, results_dir=None, use_console=True, |
Aviv Keshet | e43bccf | 2013-08-14 14:11:59 -0700 | [diff] [blame] | 14 | verbose=False, no_console_prefix=False, |
| 15 | debug_log_name=None): |
showard | 10d8417 | 2009-06-18 23:16:50 +0000 | [diff] [blame] | 16 | if no_console_prefix: |
| 17 | self.console_formatter = logging.Formatter() |
| 18 | |
| 19 | super(ServerLoggingConfig, self).configure_logging(use_console, verbose) |
showard | 75cdfee | 2009-06-10 17:40:41 +0000 | [diff] [blame] | 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) |
Aviv Keshet | e43bccf | 2013-08-14 14:11:59 -0700 | [diff] [blame] | 25 | self.add_debug_file_handlers(log_dir, log_name=debug_log_name) |