• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1import logging, logging.handlers, time, os
2import common
3from autotest_lib.client.common_lib import global_config
4from autotest_lib.site_utils import rpc_logserver
5
6
7config = global_config.global_config
8LOGGING_ENABLED = config.get_config_value('SERVER', 'rpc_logging', type=bool)
9
10rpc_logger = None
11
12
13def configure_logging():
14    logserver_enabled = config.get_config_value(
15            'SERVER', 'rpc_logserver', type=bool)
16    if logserver_enabled:
17        handler = logging.handlers.SocketHandler(
18                'localhost', rpc_logserver.DEFAULT_PORT)
19    else:
20        handler = rpc_logserver.get_logging_handler()
21
22    global rpc_logger
23    rpc_logger = logging.getLogger('rpc_logger')
24    rpc_logger.addHandler(handler)
25    rpc_logger.propagate = False
26    rpc_logger.setLevel(logging.DEBUG)
27
28
29if LOGGING_ENABLED:
30    configure_logging()
31