Home | Trees | Indices | Help |
---|
|
1 # -*- encoding: utf-8 -*- 2 ############################################################################## 3 # 4 # ETL system- Extract Transfer Load system 5 # Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). All Rights Reserved 6 # $Id$ 7 # 8 # This program is free software: you can redistribute it and/or modify 9 # it under the terms of the GNU General Public License as published by 10 # the Free Software Foundation, either version 3 of the License, or 11 # (at your option) any later version. 12 # 13 # This program is distributed in the hope that it will be useful, 14 # but WITHOUT ANY WARRANTY; without even the implied warranty of 15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 # GNU General Public License for more details. 17 # 18 # You should have received a copy of the GNU General Public License 19 # along with this program. If not, see <http://www.gnu.org/licenses/>. 20 # 21 ############################################################################## 22 23 """ 24 To provide internal logging system. 25 26 Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). 27 GNU General Public License. 28 29 """ 30 import logging 31 import logging.handlers 32 import sys 33 import os 34 35 LOG_INFO = 'info' 36 LOG_WARNING = 'warn' 37 LOG_ERROR = 'error' 38 3941 logger = logging.getLogger() 42 # create a format for log messages and dates 43 formatter = logging.Formatter('[%(asctime)s] %(levelname)s: %(name)s: %(message)s', '%a %b %d %Y %H:%M:%S') 44 45 logf = '/tmp/etl_log.out' 46 handler = logging.handlers.TimedRotatingFileHandler(logf, 'D', 1, 30) 47 48 # tell the handler to use this format 49 handler.setFormatter(formatter) 50 # add the handler to the root logger 51 logger.addHandler(handler) 52 logger.setLevel(logging.INFO)53 5457 log = logging.getLogger(name) 58 level_method = getattr(log, level) 59 msg = unicode(msg) 60 61 result = msg.strip().split('\n') 62 if len(result) > 1: 63 for idx, s in enumerate(result): 64 level_method('[%02d]: %s' % (idx + 1, s,)) 65 elif result: 66 level_method(result[0])6769 logging.shutdown()70 71 init_logger() 72
Home | Trees | Indices | Help |
---|
Generated by Epydoc 3.0beta1 on Wed Apr 29 20:37:24 2009 | http://epydoc.sourceforge.net |