summaryrefslogtreecommitdiff
path: root/logservice.py
blob: baefd0fd74fcde03c51e0a4f5ea52c5c6ffab729 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
"""log utilities

Copyright (c) 2003-2004 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
http://www.logilab.fr/ -- mailto:contact@logilab.fr
"""

from warnings import warn
warn('logservice module is deprecated and will disappear in a near release. \
use logging module instead.',
     DeprecationWarning, stacklevel=2)

__revision__ = "$Id: logservice.py,v 1.5 2006-03-05 16:13:28 syt Exp $"

from logilab.common.logger import make_logger, LOG_ERR, LOG_WARN, LOG_NOTICE, \
     LOG_INFO, LOG_CRIT, LOG_DEBUG

def init_log(treshold, method='eprint', sid='common-log-service',
             logger=None, output=None):
    """init the logging system and and log methods to builtins"""
    if logger is None:
        logger = make_logger(method, treshold, sid, output=output)
    # add log functions and constants to builtins
    __builtins__.update({'log': logger.log,
                         'log_traceback' : logger.log_traceback,
                         'LOG_CRIT':   LOG_CRIT,
                         'LOG_ERR':    LOG_ERR,
                         'LOG_WARN':   LOG_WARN,
                         'LOG_NOTICE': LOG_NOTICE,
                         'LOG_INFO' :  LOG_INFO,
                         'LOG_DEBUG':  LOG_DEBUG,
                         })

init_log(LOG_ERR)