Class: Cfruby::Cfp_Logger
- Inherits:
-
Object
- Object
- Cfruby::Cfp_Logger
- Defined in:
- lib/libcfenjin/cfp_logger.rb
Overview
Handles full logging logic from Cfruby - Cfp_liblogger
calls into this
Instance Attribute Summary collapse
-
#dry_run ⇒ Object
readonly
Returns the value of attribute dry_run.
-
#quiet_mode ⇒ Object
readonly
Returns the value of attribute quiet_mode.
-
#tracelevel ⇒ Object
readonly
Returns the value of attribute tracelevel.
-
#verbose ⇒ Object
readonly
Returns the value of attribute verbose.
Instance Method Summary collapse
-
#acting(msg = nil) ⇒ Object
Log change activity using the message set with
help
. -
#change(level, msg, progname = nil) ⇒ Object
Show change notification message based on verbosity level.
-
#error(level, msg, progname = nil) ⇒ Object
Raise exception when
level
is LOG_CRIT or less, showing error level (see alsowarn
). -
#help(msg, action = 'unknown') ⇒ Object
Records the
msg
andaction
which are used later in a method when it callstest
,status
oract
. -
#initialize(cf, verbose, trace, dry_run, quiet_mode) ⇒ Cfp_Logger
constructor
A new instance of Cfp_Logger.
-
#notify(level, msg, progname = nil) ⇒ Object
Show activity messages based on verbosity level.
-
#status(msg = nil) ⇒ Object
Log testing status using the message set with
help
. -
#testing(msg = nil) ⇒ Object
Log testing activity using the message set with
help
. -
#trace(level, msg, progname = nil) ⇒ Object
Show trace - using levels:.
-
#warn(level, msg, progname = nil) ⇒ Object
Alias for
notify
.
Constructor Details
#initialize(cf, verbose, trace, dry_run, quiet_mode) ⇒ Cfp_Logger
Returns a new instance of Cfp_Logger.
36 37 38 39 40 41 42 |
# File 'lib/libcfenjin/cfp_logger.rb', line 36 def initialize cf,verbose,trace,dry_run,quiet_mode @cf = cf @verbose = verbose @tracelevel = trace @dry_run = dry_run @quiet_mode = quiet_mode end |
Instance Attribute Details
#dry_run ⇒ Object (readonly)
Returns the value of attribute dry_run.
32 33 34 |
# File 'lib/libcfenjin/cfp_logger.rb', line 32 def dry_run @dry_run end |
#quiet_mode ⇒ Object (readonly)
Returns the value of attribute quiet_mode.
33 34 35 |
# File 'lib/libcfenjin/cfp_logger.rb', line 33 def quiet_mode @quiet_mode end |
#tracelevel ⇒ Object (readonly)
Returns the value of attribute tracelevel.
34 35 36 |
# File 'lib/libcfenjin/cfp_logger.rb', line 34 def tracelevel @tracelevel end |
#verbose ⇒ Object (readonly)
Returns the value of attribute verbose.
34 35 36 |
# File 'lib/libcfenjin/cfp_logger.rb', line 34 def verbose @verbose end |
Instance Method Details
#acting(msg = nil) ⇒ Object
Log change activity using the message set with help
140 141 142 143 144 |
# File 'lib/libcfenjin/cfp_logger.rb', line 140 def acting msg=nil msg = @msg if !msg notify(1,"#{@action}ing #{msg}") yield if !dry_run end |
#change(level, msg, progname = nil) ⇒ Object
Show change notification message based on verbosity level. Use this logger only when a change happens to the system.
See notify
for verbosity levels
109 110 111 112 |
# File 'lib/libcfenjin/cfp_logger.rb', line 109 def change level, msg, progname=nil raise "unknown value for level #{level}" if level>VERBOSE_MINOR or level<VERBOSE_CRITICAL print mkmsg('changed',level,msg,progname) if !@quiet_mode and level <= @verbose end |
#error(level, msg, progname = nil) ⇒ Object
Raise exception when level
is LOG_CRIT or less, showing error level (see also warn
)
LOG_EMERG (1) A panic condition. This is normally broadcast to all
users.
LOG_ALERT (2) A condition that should be corrected immediately, such as a
corrupted system database.
LOG_CRIT (3) Critical conditions, e.g., hard device errors.
LOG_ERR (4) Errors.
LOG_WARNING (5) Warning messages.
LOG_NOTICE (6) Conditions that are not error conditions, but should possi-
bly be handled specially.
LOG_INFO (7) Informational messages.
LOG_DEBUG (8) Messages that contain information normally of use only when
debugging a program.
66 67 68 69 70 71 72 73 |
# File 'lib/libcfenjin/cfp_logger.rb', line 66 def error level, msg, progname=nil raise "unknown value for level #{level}" if level<LOG_EMERG or level>LOG_DEBUG if level > LOG_CRIT print mkmsg('error',level,msg,progname) else raise mkmsg('fatal error',level,msg,progname) end end |
#help(msg, action = 'unknown') ⇒ Object
Records the msg
and action
which are used later in a method when it calls test
, status
or act
. Returns a pointer to self
118 119 120 121 122 |
# File 'lib/libcfenjin/cfp_logger.rb', line 118 def help(msg,action='unknown') @msg = msg @action = action self end |
#notify(level, msg, progname = nil) ⇒ Object
Show activity messages based on verbosity level. Activities do not imply a change to the system
VERBOSE_CRITICAL (1) Critical notification
VERBOSE_MAJOR (2) Major notification
VERBOSE_MINOR (3) Minor notification
93 94 95 96 |
# File 'lib/libcfenjin/cfp_logger.rb', line 93 def notify level,msg,progname=nil raise "unknown value for level #{level}" if level>VERBOSE_MINOR or level<VERBOSE_CRITICAL print mkmsg('info',level,msg,progname) if !@quiet_mode and level <= @verbose end |
#status(msg = nil) ⇒ Object
Log testing status using the message set with help
133 134 135 136 |
# File 'lib/libcfenjin/cfp_logger.rb', line 133 def status msg=nil msg = @msg if !msg notify(2,"status #{@action} #{msg}") end |
#testing(msg = nil) ⇒ Object
Log testing activity using the message set with help
126 127 128 129 |
# File 'lib/libcfenjin/cfp_logger.rb', line 126 def testing msg=nil msg = @msg if !msg notify(3,"test #{@action} #{msg}") end |
#trace(level, msg, progname = nil) ⇒ Object
Show trace - using levels:
TRACE_LIBRARY (1) Library (scripting) level
TRACE_ENGINE (2) Engine level
TRACE_ALL (3) Trace all
81 82 83 84 |
# File 'lib/libcfenjin/cfp_logger.rb', line 81 def trace level, msg, progname=nil raise "unknown value for level #{level}" if level<TRACE_LIBRARY or level>TRACE_ALL print mkmsg('trace',level,msg,progname) if level <= @tracelevel end |
#warn(level, msg, progname = nil) ⇒ Object
Alias for notify
100 101 102 |
# File 'lib/libcfenjin/cfp_logger.rb', line 100 def warn level,msg,progname=nil notify level,msg,progname end |