MCPcopy Create free account
hub / github.com/wal-e/wal-e / configure

Function configure

wal_e/log_help.py:32–108  ·  view source on GitHub ↗

Configure logging. Borrowed from logging.basicConfig Uses the IndentFormatter instead of the regular Formatter Also, opts the caller into Syslog output, unless syslog could not be opened for some reason or another, in which case a warning will be printed to the other log

(*args, **kwargs)

Source from the content-addressed store, hash-verified

30
31
32def configure(*args, **kwargs):
33 """
34 Configure logging.
35
36 Borrowed from logging.basicConfig
37
38 Uses the IndentFormatter instead of the regular Formatter
39
40 Also, opts the caller into Syslog output, unless syslog could not
41 be opened for some reason or another, in which case a warning will
42 be printed to the other log handlers.
43
44 """
45 # Configuration must only happen once: no mechanism for avoiding
46 # duplication of handlers exists.
47 assert len(HANDLERS) == 0
48
49 log_destinations = get_log_destinations()
50
51 if 'stderr' in log_destinations:
52 # Add stderr output.
53 HANDLERS.append(logging.StreamHandler())
54
55 def terrible_log_output(s):
56 import sys
57
58 print(s, file=sys.stderr)
59
60 places = [
61 # Linux
62 '/dev/log',
63
64 # FreeBSD
65 '/var/run/log',
66
67 # Macintosh
68 '/var/run/syslog',
69 ]
70
71 default_syslog_address = places[0]
72 for p in places:
73 if path.exists(p):
74 default_syslog_address = p
75 break
76
77 syslog_address = kwargs.setdefault('syslog_address',
78 default_syslog_address)
79
80 valid_facility = False
81 if 'syslog' in log_destinations:
82 facility, valid_facility = get_syslog_facility()
83
84 if not valid_facility:
85 terrible_log_output('invalid syslog facility level specified')
86
87 try:
88 # Add syslog output.
89 HANDLERS.append(handlers.SysLogHandler(syslog_address,

Callers

nothing calls this directly

Calls 7

get_log_destinationsFunction · 0.85
get_syslog_facilityFunction · 0.85
terrible_log_outputFunction · 0.85
IndentFormatterClass · 0.85
set_levelFunction · 0.85
formatMethod · 0.80
getMethod · 0.80

Tested by

no test coverage detected