Debian Codegraph @

Pyro5/__init__.py

raw
1 """
2 Pyro package. Some generic init stuff to set up logging etc.
3
4 Pyro - Python Remote Objects. Copyright by Irmen de Jong ([email protected]).
5 """
6
7 __version__ = "5.16"
8 __author__ = "Irmen de Jong"
9
10
11 def __configure_logging():
12 """Do some basic config of the logging module at package import time.
13 The configuring is done only if the PYRO_LOGLEVEL env var is set.
14 If you want to use your own logging config, make sure you do
15 that before any Pyro imports. Then Pyro will skip the autoconfig.
16 Set the env var PYRO_LOGFILE to change the name of the autoconfigured
17 log file (default is pyro5.log in the current dir). Use '{stderr}' to
18 make the log go to the standard error output."""
19 import os
20 import logging
21
22 level = os.environ.get("PYRO_LOGLEVEL")
23 logfilename = os.environ.get("PYRO_LOGFILE", "pyro5.log")
24 if level:
25 levelvalue = getattr(logging, level)
26 if len(logging.root.handlers) == 0:
27 logging.basicConfig(
28 level=levelvalue,
29 filename=None if logfilename == "{stderr}" else logfilename,
30 datefmt="%Y-%m-%d %H:%M:%S",
31 format="[%(asctime)s.%(msecs)03d,%(name)s,%(levelname)s] %(message)s"
32 )
33 log = logging.getLogger("Pyro5")
34 log.info("Pyro log configured using built-in defaults, level=%s", level)
35 else:
36 # PYRO_LOGLEVEL is not set, disable Pyro logging. No message is printed about this fact.
37 log = logging.getLogger("Pyro5")
38 log.setLevel(9999)
39 return logfilename, None
40 return logfilename, level or None
41
42
43 _pyro_logfile, _pyro_loglevel = __configure_logging()
44
45 from .configure import global_config as config