~openerp-dev/openobject-client/trunk-add-datetime-in-logfile-rga

« back to all changes in this revision

Viewing changes to bin/loglevel.py

  • Committer: RGA(OpenERP)
  • Date: 2011-03-10 10:55:15 UTC
  • Revision ID: rga@tinyerp.com-20110310105515-nwxg46hrpempt3if
[Imp] Logger:windows specific changes

Show diffs side-by-side

added added

removed removed

Lines of Context:
79
79
        format = '%s %s' % (release.description, release.version) \
80
80
                + ':%(dbname)s:%(levelname)s:%(name)s:%(message)s'
81
81
                
82
 
    elif options.options['logging.logfile']:
 
82
    if options.options['logging.logfile']:
83
83
        # LogFile Handler
84
84
        logf = options.options['logging.logfile']
85
85
        try:
91
91
            elif os.name == 'posix':
92
92
                handler = logging.handlers.WatchedFileHandler(logf)
93
93
            else:
94
 
                handler = logging.handlers.FileHandler(logf)
 
94
                handler = logging.FileHandler(logf)
95
95
        except Exception, e:
96
96
            sys.stderr.write("ERROR: couldn't create the logfile directory. Logging to the standard output.\n")
97
97
            handler = logging.StreamHandler(sys.stdout)
99
99
        # Normal Handler on standard output
100
100
        handler = logging.StreamHandler(sys.stdout)
101
101
      
102
 
    if isinstance(handler, logging.StreamHandler) and os.isatty(handler.stream.fileno()):
 
102
    if isinstance(handler, logging.StreamHandler) and getattr(handler.stream, 'isatty', None):
103
103
        formatter = ColoredFormatter(format)
104
104
    else:
105
105
        formatter = DBFormatter(format)