API reference - Class Logger

Notation used in Ruby API documentation

Description: A logger

The logger allows to output messages to the log channels. If the log viewer is open, the log messages will be shown in the logger view. Otherwise they will be printed to the terminal on Linux for example.

A code example:

RBA::Logger::error("An error message")
RBA::Logger::warn("A warning")

This class has been introduced in version 0.23.

Public methods

voidcreateEnsures the C++ object is created
voiddestroyExplicitly destroy the object
[const]booldestroyed?Returns a value indicating whether the object was already destroyed
[const]boolis_const_object?Returns a value indicating whether the reference is a const reference

Public static methods and constants

voiderror(string msg)Writes the given string to the error channel
voidinfo(string msg)Writes the given string to the info channel
voidlog(string msg)Writes the given string to the log channel
intverbosityReturns the verbosity level
voidverbosity=(int v)Sets the verbosity level for the application
voidwarn(string msg)Writes the given string to the warning channel

Detailed description

void create

Description: Ensures the C++ object is created

Use this method to ensure the C++ object is created, for example to ensure that resources are allocated. Usually C++ objects are created on demand and not necessarily when the script object is created.

void destroy

Description: Explicitly destroy the object

Explicitly destroy the object on C++ side if it was owned by the Ruby interpreter. Subsequent access to this object will throw an exception. If the object is not owned by Ruby, this method will do nothing.

[const] bool destroyed?

Description: Returns a value indicating whether the object was already destroyed

This method returns true, if the object was destroyed, either explicitly or by the C++ side. The latter may happen, if the object is owned by a C++ object which got destroyed itself.

[static] void error(string msg)

Description: Writes the given string to the error channel

The error channel is formatted as an error (i.e. red in the logger window) and output unconditionally.

[static] void info(string msg)

Description: Writes the given string to the info channel

The info channel is printed as neutral messages unconditionally.

[const] bool is_const_object?

Description: Returns a value indicating whether the reference is a const reference

This method returns true, if self is a const reference. In that case, only const methods may be called on self.

[static] void log(string msg)

Description: Writes the given string to the log channel

Log messages are printed as neutral messages and are output only if the verbosity is above 0.

[static] int verbosity

Description: Returns the verbosity level

The verbosity level is defined by the application (see -d command line option for example). Level 0 is silent, levels 10, 20, 30 etc. denote levels with increasing verbosity. 11, 21, 31 .. are sublevels which also enable timing logs in addition to messages.

[static] void verbosity=(int v)

Description: Sets the verbosity level for the application

See verbosity for a definition of the verbosity levels. Please note that this method changes the verbosity level for the whole application.

[static] void warn(string msg)

Description: Writes the given string to the warning channel

The warning channel is formatted as a warning (i.e. blue in the logger window) and output unconditionally.