Module EDLogging
[hide private]
[frames] | no frames]

Source Code for Module EDLogging

  1  # 
  2  #    Project: The EDNA Kernel 
  3  #             http://www.edna-site.org 
  4  # 
  5  #    File: "$Id: EDVerbose.py 2300 2010-10-28 12:49:04Z svensson $" 
  6  # 
  7  #    Copyright (C) 2008-2009 European Synchrotron Radiation Facility 
  8  #                            Grenoble, France 
  9  # 
 10  #    Principal authors: Olof Svensson (svensson@esrf.fr)  
 11  # 
 12  #    This program is free software: you can redistribute it and/or modify 
 13  #    it under the terms of the GNU Lesser General Public License as published 
 14  #    by the Free Software Foundation, either version 3 of the License, or 
 15  #    (at your option) any later version. 
 16  # 
 17  #    This program is distributed in the hope that it will be useful, 
 18  #    but WITHOUT ANY WARRANTY; without even the implied warranty of 
 19  #    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
 20  #    GNU Lesser General Public License for more details. 
 21  # 
 22  #    You should have received a copy of the GNU General Public License 
 23  #    and the GNU Lesser General Public License  along with this program.   
 24  #    If not, see <http://www.gnu.org/licenses/>. 
 25  # 
 26   
 27  # 
 28  # This class has been inspired by the corresponding AALib class  
 29  # (20090518-PyAALib-JyAALib-111) and modified according to the needs  
 30  # for the EDNA project. 
 31  # 
 32   
 33  __authors__ = ["Olof Svensson", "Jerome Kieffer"] 
 34  __contact__ = "svensson@esrf.fr" 
 35  __license__ = "LGPLv3+" 
 36  __copyright__ = "European Synchrotron Radiation Facility, Grenoble, France" 
 37   
 38   
 39  from EDObject import EDObject 
 40  from EDLoggingVerbose import EDLoggingVerbose 
 41  from EDLoggingPyLogging import EDLoggingPyLogging 
 42   
 43   
44 -class EDLogging(EDObject):
45 """ 46 This class loads one of the EDNA loggers: EDLoggingVerbose, EDLoggingClass 47 """ 48 49
50 - def __init__(self, _strLoggerName="EDVerbose"):
51 EDObject.__init__(self) 52 if _strLoggerName == "PyLogging": 53 self.edLogging = EDLoggingPyLogging() 54 else: 55 self.edLogging = EDLoggingVerbose()
56 57
58 - def setLogLevel(self, _logLevel):
59 self.edLogging.setLogLevel(_logLevel)
60 61
62 - def setAllLogLevels(self, _logLevel):
63 self.edLogging.setAllLogLevels(_logLevel)
64 65
66 - def setTestOn(self):
67 """ 68 turn on the test mode: all assertions become verbose (->screen) 69 """ 70 self.edLogging.setTestOn()
71 72
73 - def setTestOff(self):
74 """ 75 turn off the test mode: all assertions become silent (->screen) 76 """ 77 self.edLogging.setTestOff()
78 79
80 - def setVerboseOn(self):
81 """ 82 This method turns on verbose logging to standard output (stdout) 83 """ 84 self.edLogging.setVerboseOn()
85 86
87 - def setVerboseOff(self):
88 """ 89 This method turns off verbose logging to standard output (stdout) 90 """ 91 self.edLogging.setVerboseOff()
92 93
94 - def setVerboseDebugOn(self):
95 """ 96 This method turns on debug messages to standard output and log file 97 """ 98 self.edLogging.setVerboseDebugOn()
99 100
101 - def setVerboseDebugOff(self):
102 """ 103 This method turns off debug messages to standard output and log file 104 """ 105 self.edLogging.setVerboseDebugOff()
106 107
108 - def isVerboseDebug(self):
109 """ 110 This method returns the current status of debugging 111 112 @return: if debug output to standard output and log file is enabled. 113 @type: boolean 114 """ 115 return self.edLogging.isVerboseDebug()
116 117
118 - def log(self, _strMessage=""):
119 """ 120 This method writes a message only to the log file. 121 122 @param _strMessage: The string to be written to the log file 123 @type _strMessage: python string 124 """ 125 self.edLogging.log(_strMessage)
126
127 - def screen(self, _strMessage=""):
128 """ 129 This method writes a message to standard output and to the log file. 130 131 @param _strMessage: The string to be written to the log file 132 @type _strMessage: python string 133 """ 134 self.edLogging.screen(_strMessage)
135 136
137 - def DEBUG(self, _strDebugMessage=""):
138 """ 139 This method writes a debug message to standard output and to the log file 140 if debugging is enabled. The message will be written with the prefix [DEBUG] 141 142 @param _strDebugMessage: The debug message to be written to standard output and log file 143 @type _strDebugMessage: python string 144 """ 145 self.edLogging.DEBUG(_strDebugMessage)
146 147
148 - def unitTest(self, _strMessage=""):
149 """ 150 This method is meant to be used by the testing framework. The message will be written 151 to standard output and the log file with the prefix [UnitTest] 152 153 @param _strMessage: The message to be written to standard output and log file 154 @type _strMessage: python string 155 """ 156 self.edLogging.unitTest(_strMessage)
157 158
159 - def ERROR(self, _strMessage=""):
160 """ 161 This method writes a message to standard error and the log file with the prefix [ERROR]. 162 163 @param _strMessage: The error message to be written to standard output and log file 164 @type _strMessage: python string 165 """ 166 self.edLogging.ERROR(_strMessage)
167 168
169 - def error(self, _strMessage=""):
170 """ 171 This method writes a message to standard error and the log file with the prefix [ERROR]. 172 173 @param _strMessage: The error message to be written to standard output and log file 174 @type _strMessage: python string 175 """ 176 self.edLogging.error(_strMessage)
177 178
179 - def WARNING(self, _strMessage=""):
180 """ 181 This method writes a warning message to standard output and the log file with the prefix [Warning]. 182 183 @param _strMessage: The error message to be written to standard output and log file 184 @type _strMessage: python string 185 """ 186 self.edLogging.WARNING(_strMessage)
187 188 189
190 - def warning(self, _strMessage=""):
191 """ 192 This method writes a warning message to standard output and the log file with the prefix [Warning]. 193 194 @param _strMessage: The error message to be written to standard output and log file 195 @type _strMessage: python string 196 """ 197 self.edLogging.warning(_strMessage)
198 199
200 - def ASSERT(self, _strMessage):
201 """ 202 This method writes an assert message to standard output and the log file with the prefix [ASSERT]. 203 204 @param _strMessage: The error message to be written to standard output and log file 205 @type _strMessage: python string 206 """ 207 self.edLogging.ASSERT(_strMessage)
208
209 - def writeErrorTrace(self, _strPrefix=" "):
210 """ 211 This method writes an error trace to standard output and the log file. The error trace has 212 the same formatting as normal Python error traces. 213 214 @param _strPrefix: A prefix which can be customized, e.g. the testing framework uses ' [UnitTest]' 215 @type _strPrefix: python string 216 """ 217 self.edLogging.writeErrorTrace(_strPrefix)
218 219
220 - def setLogFileName(self, _strLogFileName):
221 """ 222 This method can be used for customising the file name of the log file. 223 224 @param _strLogFileName: A file name for the log file. 225 @type _strLogFileName: python string 226 """ 227 self.edLogging.setLogFileName(_strLogFileName)
228 229
230 - def setLogFileOff(self):
231 """ 232 This method truns off output to the log file. 233 """ 234 self.edLogging.setLogFileOff()
235