Class: ItunesController::ItunesControllerLogging
- Inherits:
-
Object
- Object
- ItunesController::ItunesControllerLogging
- Defined in:
- lib/itunesController/logging.rb
Constant Summary collapse
- DEBUG =
1
- INFO =
2
- WARN =
3
- ERROR =
4
- @@logFile =
The log file, if defined then logging opertions will be sent to this file
nil
- @@logLevel =
INFO
Class Method Summary collapse
-
.debug(msg) ⇒ Object
Used to print logging information at debug level.
-
.error(msg, exception = nil) ⇒ Object
Used to print logging information at debug level.
-
.info(msg) ⇒ Object
Used to print logging information at info level.
-
.setLogFile(file) ⇒ Object
Used to set the location of the log file.
-
.setLogLevel(level) ⇒ Object
Use to set the loggin level.
- .setLogLevelFromString(level) ⇒ Object
-
.warn(msg) ⇒ Object
Used to print logging information at warn level.
Class Method Details
.debug(msg) ⇒ Object
Used to print logging information at debug level
79 80 81 82 83 84 |
# File 'lib/itunesController/logging.rb', line 79 def self.debug(msg) if @@logLevel <= DEBUG msg="DEBUG:"+msg printMsg(msg) end end |
.error(msg, exception = nil) ⇒ Object
Used to print logging information at debug level
89 90 91 92 93 94 95 96 97 98 99 100 |
# File 'lib/itunesController/logging.rb', line 89 def self.error(msg,exception=nil) if @@logLevel <= ERROR msg="ERROR:"+msg printMsg(msg,true) if (exception!=nil) printMsg(" - #{exception.}",true) exception.backtrace.each do | line | printMsg(" * #{line}",true) end end end end |
.info(msg) ⇒ Object
Used to print logging information at info level
63 64 65 66 67 |
# File 'lib/itunesController/logging.rb', line 63 def self.info(msg) if @@logLevel <= INFO printMsg(msg) end end |
.setLogFile(file) ⇒ Object
Used to set the location of the log file
36 37 38 |
# File 'lib/itunesController/logging.rb', line 36 def self.setLogFile(file) @@logFile = file end |
.setLogLevel(level) ⇒ Object
Use to set the loggin level
42 43 44 |
# File 'lib/itunesController/logging.rb', line 42 def self.setLogLevel(level) @@logLevel = level end |
.setLogLevelFromString(level) ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/itunesController/logging.rb', line 46 def self.setLogLevelFromString(level) if (level=="DEBUG") @@logLevel = DEBUG elsif (level=="INFO") @@logLevel = INFO elsif (level=="WARN") @@logLevel = WARN elsif (level=="ERROR") @@logLevel = ERROR else error("Unkown log configuration '#{level}'") exit(1) end end |
.warn(msg) ⇒ Object
Used to print logging information at warn level
71 72 73 74 75 |
# File 'lib/itunesController/logging.rb', line 71 def self.warn(msg) if @@logLevel <= WARN printMsg(msg) end end |