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.
32 33 34 35 36 37 38 |
# File 'lib/libcfenjin/cfp_logger.rb', line 32 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.
28 29 30 |
# File 'lib/libcfenjin/cfp_logger.rb', line 28 def dry_run @dry_run end |
#quiet_mode ⇒ Object (readonly)
Returns the value of attribute quiet_mode.
29 30 31 |
# File 'lib/libcfenjin/cfp_logger.rb', line 29 def quiet_mode @quiet_mode end |
#tracelevel ⇒ Object (readonly)
Returns the value of attribute tracelevel.
30 31 32 |
# File 'lib/libcfenjin/cfp_logger.rb', line 30 def tracelevel @tracelevel end |
#verbose ⇒ Object (readonly)
Returns the value of attribute verbose.
30 31 32 |
# File 'lib/libcfenjin/cfp_logger.rb', line 30 def verbose @verbose end |
Instance Method Details
#acting(msg = nil) ⇒ Object
Log change activity using the message set with help
136 137 138 139 140 |
# File 'lib/libcfenjin/cfp_logger.rb', line 136 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
105 106 107 108 |
# File 'lib/libcfenjin/cfp_logger.rb', line 105 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.
62 63 64 65 66 67 68 69 |
# File 'lib/libcfenjin/cfp_logger.rb', line 62 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
114 115 116 117 118 |
# File 'lib/libcfenjin/cfp_logger.rb', line 114 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
89 90 91 92 |
# File 'lib/libcfenjin/cfp_logger.rb', line 89 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
129 130 131 132 |
# File 'lib/libcfenjin/cfp_logger.rb', line 129 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
122 123 124 125 |
# File 'lib/libcfenjin/cfp_logger.rb', line 122 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
77 78 79 80 |
# File 'lib/libcfenjin/cfp_logger.rb', line 77 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
96 97 98 |
# File 'lib/libcfenjin/cfp_logger.rb', line 96 def warn level,msg,progname=nil notify level,msg,progname end |