comparison gpp/core/logging.py @ 1:dbd703f7d63a

Initial import of sg101 stuff from private repository.
author gremmie
date Mon, 06 Apr 2009 02:43:12 +0000
parents
children
comparison
equal deleted inserted replaced
0:900ba3c7b765 1:dbd703f7d63a
1 '''This module adds a simple logging facility to the portal.
2 Applications can log information to a database table for debugging.
3 The logger is similar to the python logging module.
4 The verbosity of the logging is controlled via settings.GPP_LOG_LEVEL.
5 '''
6
7 from settings import GPP_LOG_LEVEL
8 from core.models import DebugLog
9
10 DEBUG = 10
11 INFO = 20
12 WARNING = 30
13 ERROR = 40
14 CRITICAL = 50
15
16 def log(level, msg):
17 if GPP_LOG_LEVEL <= level:
18 log_item = DebugLog()
19 log_item.level = level
20 log_item.msg = msg
21 log_item.save()
22
23 def debug(msg):
24 log(DEBUG, msg)
25
26 def info(msg):
27 log(INFO, msg)
28
29 def warning(msg):
30 log(WARNING, msg)
31
32 def error(msg):
33 log(WARNING, msg)
34
35 def critical(msg):
36 log(WARNING, msg)