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

Source Code for Module EDVerbose

  1  # 
  2  #    Project: The EDNA Kernel 
  3  #             http://www.edna-site.org 
  4  # 
  5  #    File: "$Id$" 
  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 EDLogging import EDLogging 
 40   
 41   
42 -class EDVerbose(object):
43 """ 44 This class is meant to be used statically for all logging 45 purposes in the EDNA framework. 46 47 All methods are thread safe. 48 """ 49 __edLogging = EDLogging("EDVerbose") 50 51
52 - def setTestOn():
53 """ 54 turn on the test mode: all assertions become verbose (->screen) 55 """ 56 EDVerbose.__edLogging.setTestOn()
57 setTestOn = staticmethod(setTestOn) 58 59
60 - def setTestOff():
61 """ 62 turn off the test mode: all assertions become silent (->screen) 63 """ 64 EDVerbose.__edLogging.setTestOff()
65 setTestOff = staticmethod(setTestOff) 66 67
68 - def setVerboseOn():
69 """ 70 This method turns on verbose logging to standard output (stdout) 71 """ 72 EDVerbose.__edLogging.setVerboseOn()
73 setVerboseOn = staticmethod(setVerboseOn) 74 75
76 - def setVerboseOff():
77 """ 78 This method turns off verbose logging to standard output (stdout) 79 """ 80 EDVerbose.__edLogging.setVerboseOff()
81 setVerboseOff = staticmethod(setVerboseOff) 82 83
84 - def setVerboseDebugOn():
85 """ 86 This method turns on debug messages to standard output and log file 87 """ 88 EDVerbose.__edLogging.setVerboseDebugOn()
89 setVerboseDebugOn = staticmethod(setVerboseDebugOn) 90 91
92 - def setVerboseDebugOff():
93 """ 94 This method turns off debug messages to standard output and log file 95 """ 96 EDVerbose.__edLogging.setVerboseDebugOff()
97 setVerboseDebugOff = staticmethod(setVerboseDebugOff) 98 99
100 - def isVerboseDebug():
101 """ 102 This method returns the current status of debugging 103 104 @return: if debug output to standard output and log file is enabled. 105 @type: boolean 106 """ 107 return EDVerbose.__edLogging.isVerboseDebug()
108 isVerboseDebug = staticmethod(isVerboseDebug) 109 110
111 - def log(_strMessage=""):
112 """ 113 This method writes a message only to the log file. 114 115 @param _strMessage: The string to be written to the log file 116 @type _strMessage: python string 117 """ 118 EDVerbose.__edLogging.log(_strMessage)
119 log = staticmethod(log) 120 121
122 - def screen(_strMessage=""):
123 """ 124 This method writes a message to standard output and to the log file. 125 126 @param _strMessage: The string to be written to the log file 127 @type _strMessage: python string 128 """ 129 EDVerbose.__edLogging.screen(_strMessage)
130 screen = staticmethod(screen) 131 132
133 - def DEBUG(_strDebugMessage=""):
134 """ 135 This method writes a debug message to standard output and to the log file 136 if debugging is enabled. The message will be written with the prefix [DEBUG] 137 138 @param _strDebugMessage: The debug message to be written to standard output and log file 139 @type _strDebugMessage: python string 140 """ 141 EDVerbose.__edLogging.DEBUG(_strDebugMessage)
142 DEBUG = staticmethod(DEBUG) 143 144
145 - def unitTest(_strMessage=""):
146 """ 147 This method is meant to be used by the testing framework. The message will be written 148 to standard output and the log file with the prefix [UnitTest] 149 150 @param _strMessage: The message to be written to standard output and log file 151 @type _strMessage: python string 152 """ 153 EDVerbose.__edLogging.unitTest(_strMessage)
154 unitTest = staticmethod(unitTest) 155 156
157 - def ERROR(_strMessage=""):
158 """ 159 This method writes a message to standard error and the log file with the prefix [ERROR]. 160 161 @param _strMessage: The error message to be written to standard output and log file 162 @type _strMessage: python string 163 """ 164 EDVerbose.__edLogging.ERROR(_strMessage)
165 ERROR = staticmethod(ERROR) 166 167
168 - def error(_strMessage=""):
169 """ 170 This method writes a message to standard error and the log file with the prefix [ERROR]. 171 172 @param _strMessage: The error message to be written to standard output and log file 173 @type _strMessage: python string 174 """ 175 EDVerbose.__edLogging.error(_strMessage)
176 error = staticmethod(error) 177 178
179 - def WARNING(_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 EDVerbose.__edLogging.WARNING(_strMessage)
187 WARNING = staticmethod(WARNING) 188 189
190 - def warning(_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 EDVerbose.__edLogging.warning(_strMessage)
198 warning = staticmethod(warning) 199 200
201 - def ASSERT(_strMessage):
202 """ 203 This method writes an assert message to standard output and the log file with the prefix [ASSERT]. 204 205 @param _strMessage: The error message to be written to standard output and log file 206 @type _strMessage: python string 207 """ 208 EDVerbose.__edLogging.ASSERT(_strMessage)
209 ASSERT = staticmethod(ASSERT) 210 211
212 - def writeErrorTrace(_strPrefix=" "):
213 """ 214 This method writes an error trace to standard output and the log file. The error trace has 215 the same formatting as normal Python error traces. 216 217 @param _strPrefix: A prefix which can be customized, e.g. the testing framework uses ' [UnitTest]' 218 @type _strPrefix: python string 219 """ 220 EDVerbose.__edLogging.writeErrorTrace(_strPrefix)
221 writeErrorTrace = staticmethod(writeErrorTrace) 222 223
224 - def setLogFileName(_strLogFileName):
225 """ 226 This method can be used for customising the file name of the log file. 227 228 @param _strLogFileName: A file name for the log file. 229 @type _strLogFileName: python string 230 """ 231 EDVerbose.__edLogging.setLogFileName(_strLogFileName)
232 setLogFileName = staticmethod(setLogFileName) 233 234
235 - def setLogFileOff():
236 """ 237 This method truns off output to the log file. 238 """ 239 EDVerbose.__edLogging.setLogFileOff()
240 setLogFileOff = staticmethod(setLogFileOff)
241