comparison orpg/tools/orpg_log.py @ 0:4385a7d0efd1 grumpy-goblin

Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
author sirebral
date Tue, 14 Jul 2009 16:41:58 -0500
parents
children cab94a90f9dc
comparison
equal deleted inserted replaced
-1:000000000000 0:4385a7d0efd1
1 # Copyright (C) 2000-2001 The OpenRPG Project
2 #
3 # openrpg-dev@lists.sourceforge.net
4 #
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 2 of the License, or
8 # (at your option) any later version.
9 #
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
14 #
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software
17 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 # --
19 #
20 # File: orpg_log.py
21 # Author: Dj Gilcrease
22 # Maintainer:
23 # Version:
24 # $Id: orpg_log.py,v 1.9 2007/05/06 16:43:02 digitalxero Exp $
25 #
26 # Description: classes for orpg log messages
27 #
28
29 from orpg.orpgCore import *
30
31 class orpgLog:
32 def __init__(self, home_dir, filename='orpgRunLog '):
33 self.logToConsol = True
34 self.logLevel = 7
35 self.logName = home_dir + filename + time.strftime( '%m-%d-%Y.txt', time.localtime( time.time() ) )
36
37 def log(self, msg, type, to_consol=False):
38 if self.logToConsol or to_consol or type == ORPG_CRITICAL:
39 print msg
40
41 if type & self.logLevel:
42 #if type & self.logLevel or to_consol: #Arbitrary removal TaS.
43 logMsg = time.strftime( '[%x %X] ', time.localtime( time.time() ) ) + msg + "\n"
44 logFile = open(self.logName, "a")
45 logFile.write(logMsg)
46 logFile.close()
47
48 def setLogLevel(self, log_level):
49 self.logLevel = log_level
50
51 def getLogLevel(self):
52 return self.logLevel
53
54 def setLogName(self, log_name):
55 self.logName = log_name
56
57 def getLogName(self):
58 return self.logName
59
60 def setLogToConsol(self, bool):
61 self.logToConsol = bool
62
63 def getLogToConsol(self):
64 return self.logToConsol