Class: Wx::Log

Inherits:
Object
  • Object
show all
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.

Note:

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

See Also:

  • Overview
  • functions

Requires:

  • USE_LOG

Direct Known Subclasses

LogBuffer, LogChain, LogGui, LogStderr, LogTextCtrl

Class Method Summary collapse

Instance Method Summary collapse

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.

Parameters:

  • mask (String)

See Also:



88
# File 'lib/wx/doc/gen/log.rb', line 88

def self.add_trace_mask(mask) end

.clear_trace_masksvoid

This method returns an undefined value.

Removes all trace masks previously set with add_trace_mask.

See Also:



95
# File 'lib/wx/doc/gen/log.rb', line 95

def self.clear_trace_masks; end

.disable_timestampvoid

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.disable_timestamp; end

.dont_create_on_demandvoid

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.

Parameters:

  • enable (Boolean) (defaults to: true)

Returns:

  • (Boolean)

See Also:



212
# File 'lib/wx/doc/gen/log.rb', line 212

def self.enable_logging(enable=true) end

.flush_activevoid

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.

Parameters:

  • comp (String)

    component value for log info



15
# File 'lib/wx/doc/log.rb', line 15

def self.for_component(comp, &block) end

.get_active_targetWx::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.

Returns:



131
# File 'lib/wx/doc/gen/log.rb', line 131

def self.get_active_target; end

.get_log_levelWx::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.

Returns:

  • (Wx::LogLevel)

See Also:



168
# File 'lib/wx/doc/gen/log.rb', line 168

def self.get_log_level; end

.get_repetition_countingBoolean

Returns whether the repetition counting mode is enabled.

Returns:

  • (Boolean)


224
# File 'lib/wx/doc/gen/log.rb', line 224

def self.get_repetition_counting; end

.get_timestampWx::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.

Returns:

  • (Wx::String)


235
# File 'lib/wx/doc/gen/log.rb', line 235

def self.get_timestamp; end

.get_trace_masksWx::ArrayString

Returns the currently allowed list of string trace masks.

Returns:

  • (Wx::ArrayString)

See Also:



102
# File 'lib/wx/doc/gen/log.rb', line 102

def self.get_trace_masks; end

.get_verboseBoolean

Returns whether the verbose mode is currently active.

Returns:

  • (Boolean)


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

Parameters:

  • mask (String)

Returns:

  • (Boolean)


109
# File 'lib/wx/doc/gen/log.rb', line 109

def self.is_allowed_trace_mask(mask) end

.is_enabledBoolean

Returns true if logging is enabled at all now.

Returns:

  • (Boolean)

See Also:



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.

Parameters:

  • level (Wx::LogLevel)
  • component (String)

Returns:

  • (Boolean)

See Also:



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.

Parameters:

  • mask (String)

See Also:



117
# File 'lib/wx/doc/gen/log.rb', line 117

def self.remove_trace_mask(mask) end

.resumevoid

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.

Parameters:

Returns:

See Also:

  • set_thread_active_target


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.

Parameters:

  • component (String)

    Non-empty component name, possibly using slashes (/) to separate it into several parts.

  • level (Wx::LogLevel)

    Maximal level of log messages from this component which will be handled instead of being simply discarded.



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.

Parameters:

  • logLevel (Wx::LogLevel)

See Also:



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.

Parameters:

  • repetCounting (Boolean) (defaults to: true)


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.

Parameters:

  • format (String)


243
# File 'lib/wx/doc/gen/log.rb', line 243

def self.set_timestamp(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.

Parameters:

  • verbose (Boolean) (defaults to: true)

See Also:

  • Overview


261
# File 'lib/wx/doc/gen/log.rb', line 261

def self.set_verbose(verbose=true) end

.suspendvoid

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).

See Also:



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).

Parameters:



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.

Parameters:

  • msg (String)


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.

Parameters:

  • level (Wx::LogLevel)
  • msg (String)


314
# File 'lib/wx/doc/gen/log.rb', line 314

def do_log_text_at_level(level, msg) end

#flushvoid

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

Parameters:



293
# File 'lib/wx/doc/gen/log.rb', line 293

def log_record(level, msg, info) end