Changeset 229
- Timestamp:
- 07/20/2010 12:08:17 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
SHX/trunk/src/SeismicHandler/core/log.py
r146 r229 71 71 72 72 try: 73 logging.basicConfig(level=logging.DEBUG, 74 format='%(asctime)s %(name)-12s %(levelname)-8s %(message)s', 75 datefmt='%Y-%m-%d %H:%M:%S', 76 filename=self.logdest, 77 filemode='w') 73 logging.basicConfig( 74 level=logging.DEBUG, 75 format='%(asctime)s %(name)-12s %(levelname)-8s %(message)s', 76 datefmt='%Y-%m-%d %H:%M:%S', 77 filename=self.logdest, 78 filemode='w' 79 ) 78 80 except IOError: 79 self.warning("Cannot log to disc, path %s not writable! Logging everything to console." % dir) 81 self.warning("Cannot log to disc, path %s not writable! " 82 "Logging everything to console." % dir) 80 83 81 logging.basicConfig(level=logging.DEBUG, 82 format='%(asctime)s %(name)-12s %(levelname)-8s %(message)s', 83 datefmt='%Y-%m-%d %H:%M:%S') 84 84 logging.basicConfig( 85 level=logging.DEBUG, 86 format='%(asctime)s %(name)-12s %(levelname)-8s %(message)s', 87 datefmt='%Y-%m-%d %H:%M:%S' 88 ) 85 89 else: 86 90 # additional to console … … 90 94 91 95 # set a format which is simpler for console use 92 formatter = logging.Formatter('%(name)-12s: %(levelname)-8s %(message)s') 96 formatter = \ 97 logging.Formatter('%(name)-12s: %(levelname)-8s %(message)s') 93 98 94 99 # tell the handler to use this format … … 112 117 it may not be consistent!""" 113 118 114 # This method is called later by atexit, so we need to reimport the os115 # module.116 import os117 118 119 try: 119 120 os.rename(self.logdest, self.backupdest) 120 121 except Exception, e: 121 print e 122 pass 123 # print e 122 124 125 def newLogger(self, name): 126 """ 127 Return new logger instance. It will share the basic configuration as 128 defined in __init__. 129 """ 130 return logging.getLogger(name) 131 132 # init logging once (sets logfile, etc) 123 133 Logging() 124 125 # clean up126 # logging must be kept since it's imported from other modules127 del os
Note: See TracChangeset
for help on using the changeset viewer.