Class: Wx::Log
- Inherits:
-
Object
- Object
- Wx::Log
- Defined in:
- lib/wx/doc/gen/log.rb,
lib/wx/doc/log.rb
Overview
Log class defines the interface for the log targets used by wxWidgets logging functions as explained in the Logging Overview.
The only situations when you need to directly use this class is when you want to derive your own log target because the existing ones don’t satisfy your needs. Otherwise, it is completely hidden behind the wxLogXXX() functions and you may not even know about its existence.
For console-mode applications, the default target is LogStderr, so that all log_xxx functions print on stderr when Setup::USE_GUI = 0.
Category: Logging
Direct Known Subclasses
Class Method Summary collapse
-
.add_trace_mask(mask) ⇒ void
Add the mask to the list of allowed masks for log_trace.
-
.clear_trace_masks ⇒ void
Removes all trace masks previously set with Log.add_trace_mask.
-
.disable_timestamp ⇒ void
Disables time stamping of the log messages.
-
.dont_create_on_demand ⇒ void
Instructs Log to not create new log targets on the fly if there is none currently (see Log.get_active_target).
-
.enable_logging(enable = true) ⇒ Boolean
Globally enable or disable logging.
-
.flush_active ⇒ void
Flushes the current log target if any, does nothing if there is none.
-
.for_component(comp, &block) ⇒ Object
Sets the current component for log info to the given value before executing the given block and restores the previous component value after the block returns.
-
.get_active_target ⇒ Wx::Log
Returns the pointer to the active log target (may be NULL).
-
.get_log_level ⇒ Wx::LogLevel
Returns the current log level limit.
-
.get_repetition_counting ⇒ Boolean
Returns whether the repetition counting mode is enabled.
-
.get_timestamp ⇒ Wx::String
Returns the current timestamp format string.
-
.get_trace_masks ⇒ Wx::ArrayString
Returns the currently allowed list of string trace masks.
-
.get_verbose ⇒ Boolean
Returns whether the verbose mode is currently active.
-
.is_allowed_trace_mask(mask) ⇒ Boolean
Returns true if the mask is one of allowed masks for log_trace.
-
.is_enabled ⇒ Boolean
Returns true if logging is enabled at all now.
-
.is_level_enabled(level, component) ⇒ Boolean
Returns true if logging at this level is enabled for the current thread.
-
.remove_trace_mask(mask) ⇒ void
Remove the mask from the list of allowed masks for log_trace.
-
.resume ⇒ void
Resumes logging previously suspended by a call to Log.suspend.
-
.set_active_target(logtarget) ⇒ Wx::Log
Sets the specified log target as the active one.
-
.set_component_level(component, level) ⇒ void
Sets the log level for the given component.
-
.set_log_level(logLevel) ⇒ void
Specifies that log messages with level greater (numerically) than logLevel should be ignored and not sent to the active log target.
-
.set_repetition_counting(repetCounting = true) ⇒ void
Enables logging mode in which a log message is logged once, and in case exactly the same message successively repeats one or more times, only the number of repetitions is logged.
-
.set_timestamp(format) ⇒ void
Sets the timestamp format prepended by the default log targets to all messages.
-
.set_verbose(verbose = true) ⇒ void
Activates or deactivates verbose mode in which the verbose messages are logged as the normal ones instead of being silently dropped.
-
.suspend ⇒ void
Suspends the logging until Log.resume is called.
Instance Method Summary collapse
-
#do_log_record(level, msg, info) ⇒ void
protected
Called to log a new record.
-
#do_log_text(msg) ⇒ void
protected
Called to log the specified string.
-
#do_log_text_at_level(level, msg) ⇒ void
protected
Called to log the specified string at given level.
-
#flush ⇒ void
Show all pending output and clear the buffer.
-
#log_record(level, msg, info) ⇒ void
Log the given record.
Class Method Details
.add_trace_mask(mask) ⇒ void
This method returns an undefined value.
Add the mask to the list of allowed masks for log_trace.
88 |
# File 'lib/wx/doc/gen/log.rb', line 88 def self.add_trace_mask(mask) end |
.clear_trace_masks ⇒ void
This method returns an undefined value.
Removes all trace masks previously set with add_trace_mask.
95 |
# File 'lib/wx/doc/gen/log.rb', line 95 def self.clear_trace_masks; end |
.disable_timestamp ⇒ void
This method returns an undefined value.
Disables time stamping of the log messages.
Notice that the current time stamp is only used by the default log formatter and custom formatters may ignore calls to this function.
249 |
# File 'lib/wx/doc/gen/log.rb', line 249 def self.; end |
.dont_create_on_demand ⇒ void
This method returns an undefined value.
Instructs Wx::Log to not create new log targets on the fly if there is none currently (see get_active_target).
(Almost) for internal use only: it is supposed to be called by the application shutdown code (where you don’t want the log target to be automatically created anymore). Note that this function also calls clear_trace_masks.
124 |
# File 'lib/wx/doc/gen/log.rb', line 124 def self.dont_create_on_demand; end |
.enable_logging(enable = true) ⇒ Boolean
Globally enable or disable logging.
Calling this function with false argument disables all log messages for the current thread.
The old state, i.e. true if logging was previously enabled and false if it was disabled.
212 |
# File 'lib/wx/doc/gen/log.rb', line 212 def self.enable_logging(enable=true) end |
.flush_active ⇒ void
This method returns an undefined value.
Flushes the current log target if any, does nothing if there is none.
When this method is called from the main thread context, it also flushes any previously buffered messages logged by the other threads. When it is called from the other threads it simply calls #flush on the currently active log target, so it mostly makes sense to do this if a thread has its own logger set with set_thread_active_target.
145 |
# File 'lib/wx/doc/gen/log.rb', line 145 def self.flush_active; end |
.for_component(comp, &block) ⇒ Object
Sets the current component for log info to the given value before executing the given block and restores the previous component value after the block returns.
15 |
# File 'lib/wx/doc/log.rb', line 15 def self.for_component(comp, &block) end |
.get_active_target ⇒ Wx::Log
Returns the pointer to the active log target (may be NULL).
Notice that if set_active_target hadn’t been previously explicitly called, this function will by default try to create a log target by calling AppTraits#create_log_target which may be overridden in a user-defined traits class to change the default behaviour. You may also call dont_create_on_demand to disable this behaviour. When this function is called from threads other than main one, auto-creation doesn’t happen. But if the thread has a thread-specific log target previously set by set_thread_active_target, it is returned instead of the global one. Otherwise, the global log target is returned.
131 |
# File 'lib/wx/doc/gen/log.rb', line 131 def self.get_active_target; end |
.get_log_level ⇒ Wx::LogLevel
Returns the current log level limit.
All messages at levels strictly greater than the value returned by this function are not logged at all.
168 |
# File 'lib/wx/doc/gen/log.rb', line 168 def self.get_log_level; end |
.get_repetition_counting ⇒ Boolean
Returns whether the repetition counting mode is enabled.
224 |
# File 'lib/wx/doc/gen/log.rb', line 224 def self.get_repetition_counting; end |
.get_timestamp ⇒ Wx::String
Returns the current timestamp format string.
Notice that the current time stamp is only used by the default log formatter and custom formatters may ignore this format.
235 |
# File 'lib/wx/doc/gen/log.rb', line 235 def self.; end |
.get_trace_masks ⇒ Wx::ArrayString
Returns the currently allowed list of string trace masks.
102 |
# File 'lib/wx/doc/gen/log.rb', line 102 def self.get_trace_masks; end |
.get_verbose ⇒ Boolean
Returns whether the verbose mode is currently active.
253 |
# File 'lib/wx/doc/gen/log.rb', line 253 def self.get_verbose; end |
.is_allowed_trace_mask(mask) ⇒ Boolean
Returns true if the mask is one of allowed masks for log_trace.
See also: add_trace_mask, remove_trace_mask
109 |
# File 'lib/wx/doc/gen/log.rb', line 109 def self.is_allowed_trace_mask(mask) end |
.is_enabled ⇒ Boolean
Returns true if logging is enabled at all now.
220 |
# File 'lib/wx/doc/gen/log.rb', line 220 def self.is_enabled; end |
.is_level_enabled(level, component) ⇒ Boolean
Returns true if logging at this level is enabled for the current thread.
This function only returns true if logging is globally enabled and if level is less than or equal to the maximal log level enabled for the given component.
180 |
# File 'lib/wx/doc/gen/log.rb', line 180 def self.is_level_enabled(level, component) end |
.remove_trace_mask(mask) ⇒ void
This method returns an undefined value.
Remove the mask from the list of allowed masks for log_trace.
117 |
# File 'lib/wx/doc/gen/log.rb', line 117 def self.remove_trace_mask(mask) end |
.resume ⇒ void
This method returns an undefined value.
Resumes logging previously suspended by a call to suspend.
All messages logged in the meanwhile will be flushed soon.
151 |
# File 'lib/wx/doc/gen/log.rb', line 151 def self.resume; end |
.set_active_target(logtarget) ⇒ Wx::Log
Sets the specified log target as the active one.
Returns the pointer to the previous active log target (may be NULL). To suppress logging use a new instance of Wx::LogNull not NULL. If the active log target is set to NULL a new default log target will be created when logging occurs.
139 |
# File 'lib/wx/doc/gen/log.rb', line 139 def self.set_active_target(logtarget) end |
.set_component_level(component, level) ⇒ void
This method returns an undefined value.
Sets the log level for the given component.
For example, to disable all but error messages from wxWidgets network classes you may use
Wx::Log.set_component_level('wx/net', Wx::LOG_Error)
set_log_level may be used to set the global log level.
193 |
# File 'lib/wx/doc/gen/log.rb', line 193 def self.set_component_level(component, level) end |
.set_log_level(logLevel) ⇒ void
This method returns an undefined value.
Specifies that log messages with level greater (numerically) than logLevel should be ignored and not sent to the active log target.
201 |
# File 'lib/wx/doc/gen/log.rb', line 201 def self.set_log_level(logLevel) end |
.set_repetition_counting(repetCounting = true) ⇒ void
This method returns an undefined value.
Enables logging mode in which a log message is logged once, and in case exactly the same message successively repeats one or more times, only the number of repetitions is logged.
229 |
# File 'lib/wx/doc/gen/log.rb', line 229 def self.set_repetition_counting(repetCounting=true) end |
.set_timestamp(format) ⇒ void
This method returns an undefined value.
Sets the timestamp format prepended by the default log targets to all messages.
The string may contain any normal characters as well as % prefixed format specifiers, see strftime() manual for details. Passing an empty string to this function disables message time stamping. Notice that the current time stamp is only used by the default log formatter and custom formatters may ignore this format. You can also define a custom Wx::LogFormatter to customize the time stamp handling beyond changing its format.
243 |
# File 'lib/wx/doc/gen/log.rb', line 243 def self.(format) end |
.set_verbose(verbose = true) ⇒ void
This method returns an undefined value.
Activates or deactivates verbose mode in which the verbose messages are logged as the normal ones instead of being silently dropped.
The verbose messages are the trace messages which are not disabled in the release mode and are generated by Wx.log_verbose.
261 |
# File 'lib/wx/doc/gen/log.rb', line 261 def self.set_verbose(verbose=true) end |
.suspend ⇒ void
This method returns an undefined value.
Suspends the logging until resume is called.
Note that the latter must be called the same number of times as the former to undo it, i.e. if you call suspend twice you must call resume twice as well. Note that suspending the logging means that the log sink won’t be flushed periodically, it doesn’t have any effect if the current log target does the logging immediately without waiting for #flush to be called (the standard GUI log target only shows the log dialog when it is flushed, so suspend works as expected with it).
160 |
# File 'lib/wx/doc/gen/log.rb', line 160 def self.suspend; end |
Instance Method Details
#do_log_record(level, msg, info) ⇒ void (protected)
This method returns an undefined value.
Called to log a new record.
Any log message created by log_xxx, the corresponding prefix to msg and passes it to #do_log_text_at_level. You may override this method to implement custom formatting of the log messages or to implement custom filtering of log messages (e.g. you could discard all log messages coming from the given source file).
306 |
# File 'lib/wx/doc/gen/log.rb', line 306 def do_log_record(level, msg, info) end |
#do_log_text(msg) ⇒ void (protected)
This method returns an undefined value.
Called to log the specified string.
A simple implementation might just send the string to stdout or stderr or save it in a file (of course, the already existing Wx::LogStderr can be used for this). The base class version of this function asserts so it must be overridden if you don’t override #do_log_record or #do_log_text_at_level.
322 |
# File 'lib/wx/doc/gen/log.rb', line 322 def do_log_text(msg) end |
#do_log_text_at_level(level, msg) ⇒ void (protected)
This method returns an undefined value.
Called to log the specified string at given level.
The base class versions logs debug and trace messages on the system default debug output channel and passes all the other messages to #do_log_text.
314 |
# File 'lib/wx/doc/gen/log.rb', line 314 def do_log_text_at_level(level, msg) end |
#flush ⇒ void
This method returns an undefined value.
Show all pending output and clear the buffer.
Some of Wx::Log implementations, most notably the standard Wx::LogGui class, buffer the messages (for example, to avoid showing the user a zillion of modal message boxes one after another which would be really annoying). This function shows them all and clears the buffer contents. If the buffer is already empty, nothing happens. If you override this method in a derived class, call the base class version first, before doing anything else.
268 |
# File 'lib/wx/doc/gen/log.rb', line 268 def flush; end |
#log_record(level, msg, info) ⇒ void
This method returns an undefined value.
Log the given record.
This function should only be called from the DoLog() implementations in the derived classes if they need to call #do_log_record on another log object (they can, of course, just use #do_log_record call syntax to call it on the object itself). It should not be used for logging new messages which can be only sent to the currently active logger using OnLog() which also checks if the logging (for this level) is enabled while this method just directly calls DoLog(). Example of use of this class from Wx::LogChain:
class Wx::LogChain
def do_log_record(level, msg, info)
# let the previous logger show it
if m_logOld && is_passing_messages
m_logOld.log_record(level, msg, info)
# and also send it to the new one
if m_logNew && m_logNew != self
m_logNew.log_record(level, msg, info)
end
end
293 |
# File 'lib/wx/doc/gen/log.rb', line 293 def log_record(level, msg, info) end |