Revision cfcc79c6 lib/utils/log.py
b/lib/utils/log.py | ||
---|---|---|
22 | 22 |
|
23 | 23 |
""" |
24 | 24 |
|
25 |
import os.path |
|
25 | 26 |
import logging |
26 | 27 |
import logging.handlers |
27 | 28 |
|
... | ... | |
162 | 163 |
return logging.Formatter("".join(parts)) |
163 | 164 |
|
164 | 165 |
|
165 |
def SetupLogging(logfile, debug=0, stderr_logging=False, program="",
|
|
166 |
def SetupLogging(logfile, program, debug=0, stderr_logging=False,
|
|
166 | 167 |
multithreaded=False, syslog=constants.SYSLOG_USAGE, |
167 | 168 |
console_logging=False): |
168 | 169 |
"""Configures the logging module. |
169 | 170 |
|
170 | 171 |
@type logfile: str |
171 | 172 |
@param logfile: the filename to which we should log |
173 |
@type program: str |
|
174 |
@param program: the name under which we should log messages |
|
172 | 175 |
@type debug: integer |
173 | 176 |
@param debug: if greater than zero, enable debug messages, otherwise |
174 | 177 |
only those at C{INFO} and above level |
175 | 178 |
@type stderr_logging: boolean |
176 | 179 |
@param stderr_logging: whether we should also log to the standard error |
177 |
@type program: str |
|
178 |
@param program: the name under which we should log messages |
|
179 | 180 |
@type multithreaded: boolean |
180 | 181 |
@param multithreaded: if True, will add the thread name to the log file |
181 | 182 |
@type syslog: string |
... | ... | |
190 | 191 |
syslog/stderr logging is disabled |
191 | 192 |
|
192 | 193 |
""" |
193 |
formatter = _GetLogFormatter(program, multithreaded, debug, False) |
|
194 |
syslog_fmt = _GetLogFormatter(program, multithreaded, debug, True) |
|
194 |
progname = os.path.basename(program) |
|
195 |
|
|
196 |
formatter = _GetLogFormatter(progname, multithreaded, debug, False) |
|
197 |
syslog_fmt = _GetLogFormatter(progname, multithreaded, debug, True) |
|
195 | 198 |
|
196 | 199 |
root_logger = logging.getLogger("") |
197 | 200 |
root_logger.setLevel(logging.NOTSET) |
Also available in: Unified diff