summaryrefslogtreecommitdiff
path: root/src/logging.py
diff options
context:
space:
mode:
authorlouiz@4325f9fc-e183-4c21-96ce-0ab188b42d13 <louiz@4325f9fc-e183-4c21-96ce-0ab188b42d13>2010-01-26 19:33:40 +0000
committerlouiz@4325f9fc-e183-4c21-96ce-0ab188b42d13 <louiz@4325f9fc-e183-4c21-96ce-0ab188b42d13>2010-01-26 19:33:40 +0000
commit64d5c4b6f322990e94d999172c3eb4146724f872 (patch)
treebbf833ea5e6486707b739f1acfac4504d1100410 /src/logging.py
parent865ab0316a53a32c9caac842bbd54d233cdd2665 (diff)
downloadpoezio-64d5c4b6f322990e94d999172c3eb4146724f872.tar.gz
poezio-64d5c4b6f322990e94d999172c3eb4146724f872.tar.bz2
poezio-64d5c4b6f322990e94d999172c3eb4146724f872.tar.xz
poezio-64d5c4b6f322990e94d999172c3eb4146724f872.zip
ca fonctionne, ca clignotte, et cest gay
Diffstat (limited to 'src/logging.py')
-rw-r--r--src/logging.py24
1 files changed, 16 insertions, 8 deletions
diff --git a/src/logging.py b/src/logging.py
index 4bbedb9d..bb22e5c9 100644
--- a/src/logging.py
+++ b/src/logging.py
@@ -17,28 +17,36 @@
# You should have received a copy of the GNU General Public License
# along with Poezio. If not, see <http://www.gnu.org/licenses/>.
-from config import config
import sys
from datetime import datetime
-
+from config import config
class Logger(object):
"""
Appends things to files. Error/information/warning logs
and also log the conversations to logfiles
"""
- def __init__(self):
- self.logfile = config.get('logfile')
+ def __init__(self):# , logfile, loglevel):
+ self.logfile = config.get('logfile', 'logs')
+ self.loglevel = config.get('loglevel', 3)
+ # self.logfile = logfile
+ # self.loglevel = loglevel
+
+ def info(self, msg):
+ if self.logfile and self.loglevel >= 3:
+ fd = open(self.logfile, 'a')
+ fd.write(datetime.now().strftime("%H:%M:%S") + ' Info [' + msg + ']\n')
+ fd.close()
def warning(self, msg):
- if self.logfile:
+ if self.logfile and self.loglevel >= 2:
fd = open(self.logfile, 'a')
- fd.write(datetime.now().strftime("%H:%M:%S") + ' Warning [' + msg + ']')
+ fd.write(datetime.now().strftime("%H:%M:%S") + ' Warning [' + msg + ']\n')
fd.close()
def error(self, msg):
- if self.logfile:
+ if self.logfile and self.loglevel >= 1:
fd = open(self.logfile, 'a')
- fd.write(datetime.now().strftime("%H:%M:%S") + ' Error [' + msg + ']')
+ fd.write(datetime.now().strftime("%H:%M:%S") + ' Error [' + msg + ']\n')
fd.close()
sys.exit(-1)