~loggerhead-team/loggerhead/trunk-rich

« back to all changes in this revision

Viewing changes to loggerhead/trace.py

  • Committer: Guillermo Gonzalez
  • Date: 2008-08-23 23:42:20 UTC
  • mto: (217.1.9 logging)
  • mto: This revision was merged to the branch mainline in revision 226.
  • Revision ID: guillo.gonzo@gmail.com-20080823234220-uli3fjaxid1azb1u
 add missing imports to trace.log and new logger (error.log)

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
21
21
#
22
22
 
 
23
import os
 
24
import logging
 
25
import sys
23
26
 
24
27
def make_handler(config, filename):
25
28
    roll = config.get('log.roll', 'never')
38
41
    if not os.path.exists(log_folder):
39
42
        os.mkdir(log_folder)
40
43
 
41
 
    f = logging.Formatter('%(levelname)-.3s [%(asctime)s.%(msecs)03d] %(name)s: %(message)s',
42
 
                          '%Y%m%d-%H:%M:%S')
 
44
    f = logging.Formatter('%(levelname)-.3s [%(asctime)s.%(msecs)03d]'
 
45
                          ' %(name)s: %(message)s','%Y%m%d-%H:%M:%S')
43
46
    debug_log = make_handler(config, os.path.join(log_folder, 'debug.log'))
44
47
    debug_log.setLevel(logging.DEBUG)
45
48
    debug_log.setFormatter(f)
52
55
    access_log = make_handler(config, os.path.join(log_folder, 'access.log'))
53
56
    access_log.setLevel(logging.INFO)
54
57
    access_log.setFormatter(f)
 
58
    
 
59
    f = logging.Formatter('[%(asctime)s.%(msecs)03d] %(message)s',
 
60
                          '%Y%m%d-%H:%M:%S')
 
61
    error_log = make_handler(config, os.path.join(log_folder, 'error.log'))
 
62
    error_log.setLevel(logging.ERROR)
 
63
    error_log.setFormatter(f)
55
64
 
56
65
    logging.getLogger('').setLevel(logging.DEBUG)
57
66
    logging.getLogger('').addHandler(debug_log)
58
67
    logging.getLogger('wsgi').addHandler(access_log)
 
68
    logging.getLogger('').addHandler(error_log)
59
69
 
60
70
    if foreground:
61
 
        logging.getLogger('').addHandler(stdout_log)
 
 
b'\\ No newline at end of file'
 
71
        logging.getLogger('').addHandler(stdout_log)