|
The Vish Visualization Shell 0.3
Vish
|
Log messages, usually for analysing the program's internal flow for debugging purposes. More...
#include <ocean/plankton/VLogger.hpp>
Classes | |
| struct | Context |
| Set logging context with auto-cleanup. More... | |
| class | Indent |
| A class for setting a temporary increment of the indentation of logging text; it allows to indent logged text automatically during the lifetime of the Indent object. More... | |
| class | State |
| Describes a thread-local state of the logging process. More... | |
Public Member Functions | |
| bool | activate () |
| Activate this VLogger object. | |
| virtual void | printmsg (const string &text, int verbosity, int indent_spaces, const string &srcfilename, unsigned linenumber, const WeakPtr< VTask > &ThreadID, const string &funcname) |
| Message output function. | |
| VLogger () | |
| Constructs and adds a logging object. | |
| ~VLogger () | |
| Destructor. | |
Public Member Functions inherited from MemCore::ReferenceBase< VLogger > | |
| auto | getObjectCountID () const noexcept |
| Get a unique ID for this object in the given domain. | |
| bool | isIdentical (const WeakPtr< VLogger, VLogger > &PossibleSelf) const noexcept |
| Check if this object is identical to the one used by the given pointer. | |
| void | mkAutoDestructive () |
| Marks this object as being automatically destructed, e.g. | |
| refcount_t | refcount () const noexcept |
| The strong reference count. | |
| ReferenceBase (VLogger *that) noexcept | |
| Constructor, initializes reference counter to zero. | |
| const auto & | self () const |
| Return weak pointer to the object self. | |
| refcount_t | wrefcount () const noexcept |
| The weak reference count. | |
Static Public Member Functions | |
| static void | print (const string &text, int verbosity, int indent_spaces, const string &srcfilename, unsigned linenumber, const WeakPtr< VTask > &ThreadID, const string &funcname) |
| Verbose print function. | |
| static void | print (int verbosity, const string &s) |
| Simplified print function. | |
| static void | printf (int verbosity, const char *format,...) |
| Print formatted function with parameters. | |
Additional Inherited Members | |
Public Types inherited from MemCore::ReferenceBase< VLogger > | |
| using | reference_domain_t = VLogger |
| The type of the base class. | |
| using | SelfPtr_t = WeakPtr< VLogger, VLogger > |
| Type for a pointer to this object itself. | |
Protected Member Functions inherited from MemCore::ReferenceBase< VLogger > | |
| virtual void | extremeUnction () |
| A virtual function that will be called just before the object is destroyed. | |
| ReferenceBase & | operator= (const ReferenceBase &R) |
| Protected assignment operator (should not be called). | |
| void | suicide () |
| Delete this. | |
| virtual | ~ReferenceBase () |
| Virtual destructor. | |
Log messages, usually for analysing the program's internal flow for debugging purposes.
While using of debuggers is helpful to trace down fatal program errors leading to segmentation faults and core dumps, debugging tools are not too effective to analyse and verify the execution flow of a program. Logical errors - in contrast to simple programming errors - are hardly determinable using runtime debuggers since they only show a certain state of a program, but not the execution history. The ability to log the program's execution flow is the more effective approach for tracing higher-level errors, especcially in a multithreaded context.
This class only provides an abstraction interface to various output facilities. Multiple clients may connect to the logging instance.
The API is intentionally as simple as possible, such that application code just needs to be instrumented with print() or printf() calls. Only required addition is the specification of a verbosity level. The higher the verbosity level, the more detailed the information is, and it is the duty of the implementation of a VLogger to display logging information only up to a certain verbosity level.
The VLogger class implements a function call stack for each thread and keep track of a context when issuing print statements. This context contains the current function name, source file name, line number and indentation level. The context may be setup automatically by some external source code instrumentation tool which inserts certain code lines. However, manual instrumentation might be more effective since there doesn't need to be a 1:1 correspondence. For instance, one specific line in a source code might emit multiple logging lines, or a function should not show up explicitely since the calling function is the one providing the relevant context.
Class Derivation Example:
bool activate();
| bool Wizt::VLogger::activate | ( | ) |
Activate this VLogger object.
It must be referenced via a strongptr from some application code.
References MemCore::ReferenceBase< VLogger >::self().
|
static |
Verbose print function.
All arguments are broadcasted to all activated instances of VLogger objects.
| text | the actual text to be printed |
| verbosity | the verbosity level |
| indent_spaces | how many spaces to indent at the beginning of the line? |
| srcfilename | the file name of the source that issues this command, usually FILE |
| linenumber | the line number of the source file, usually LINE |
| ThreadID | an identifier for the thread issuing the message |
| funcname | the function context for which this function was called. |
|
virtual |
Message output function.
By default, prints message on standard output.
| text | the actual text to be printed |
| verbosity | the verbosity level |
| indent_spaces | how many spaces to indent at the beginning of the line? |
| srcfilename | the file name of the source that issues this command, usually FILE |
| linenumber | the line number of the source file, usually LINE |
| ThreadID | an identifier for the thread issuing the message |
| funcname | current function (last registered for debugging) |
Reimplemented in Wizt::VStreamLogger::Logger.
References printf().