This class acts as a container for Loggers and provides a convenient interface to logging. Fore information how to use this class, checkout the ALox tutorials and the ALox manual.
If thread safeness is not needed for the logging system (see user manual), the mutex can be switched off using inherited method ThreadLock::SetSafeness . The goal here would be to increase logging performance. This is really a very seldom case when performance is absolutely key, and it is better to be kept in safe mode.
'Logable Objects' in ALox for C++
While other ALox implementations, like ALox for C# or ALox for Java use the 'run-time type information' feature of their underlying programming language to identify any object type, in the C++ version %ALib Boxing is used to be able to log arbitrary object types.
Public Static Field Index: | |
static constexpr NString | InternalDomains { "$/" } |
Public Static Method Index: | |
static ALIB_API detail::textlogger::TextLogger * | CreateConsoleLogger (const NString &name=nullptr) |
Public Method Index: | |
Lox (const NString &name, bool doRegister=true) | |
~Lox () | |
void | Acquire (const NCString &file, int line, const NCString &func) |
template<typename... BoxedObjects> | |
void | Assert (bool condition, BoxedObjects &&... logables) |
void | ClearSourcePathTrimRules (lang::Reach reach=lang::Reach::Global, bool allowAutoRule=true) |
monomem::MonoAllocator & | DbgGetMonoAllocator () |
void | Entry (const NString &domain, Verbosity verbosity) |
template<typename... BoxedObjects> | |
void | EntryDetectDomain (Verbosity verbosity, BoxedObjects &&... logables) |
template<typename... BoxedObjects> | |
void | Error (BoxedObjects &&... logables) |
Boxes & | GetLogableContainer () |
integer & | GetLogCounter () |
detail::Logger * | GetLogger (const NString &loggerName) |
const NString & | GetName () |
void | GetState (NAString &buf, StateInfo flags=StateInfo::All) |
template<typename... BoxedObjects> | |
void | If (bool condition, const NString &domain, Verbosity verbosity, BoxedObjects &&... logables) |
template<typename... BoxedObjects> | |
void | If (bool condition, Verbosity verbosity, BoxedObjects &&... logables) |
template<typename... BoxedObjects> | |
void | Info (BoxedObjects &&... logables) |
int | IsActive (Verbosity verbosity, const NString &domain=NullNString()) |
void | MapThreadName (const String &threadName, threads::ThreadID id=0) |
void | Once (const Box &logables, const String &group, int quantity=1) |
void | Once (const Box &logables, const String &group, Scope scope, int quantity=1) |
void | Once (const Box &logables, int quantity=1) |
void | Once (const Box &logables, Scope scope, int quantity=1) |
void | Once (const NString &domain, Verbosity verbosity, const Box &logables, const String &group, Scope scope=Scope::Global, int quantity=1) |
void | Once (const NString &domain, Verbosity verbosity, const Box &logables, Scope scope=Scope::Global, int quantity=1) |
void | Once (Verbosity verbosity, const Box &logables, const String &group, int quantity=1) |
void | Once (Verbosity verbosity, const Box &logables, const String &group, Scope scope, int quantity=1) |
void | Once (Verbosity verbosity, const Box &logables, int quantity=1) |
void | Once (Verbosity verbosity, const Box &logables, Scope scope, int quantity=1) |
void | Release () |
detail::Logger * | RemoveLogger (const NString &loggerName) |
bool | RemoveLogger (detail::Logger *logger) |
void | RemoveThreadDomain (const NString &scopeDomain, Scope scope, threads::Thread *thread=nullptr) |
void | Reset (bool reInitialze=true) |
ALIB_API Box | Retrieve (const NString &key, Scope scope=Scope::Global) |
ALIB_API Box | Retrieve (Scope scope=Scope::Global) |
void | SetDomain (const NString &scopeDomain, Scope scope) |
void | SetDomain (const NString &scopeDomain, Scope scope, threads::Thread *thread) |
void | SetDomainSubstitutionRule (const NString &domainPath, const NString &replacement) |
void | SetPrefix (const Box &prefix, const NString &domain=nullptr, lang::Inclusion otherPLs=lang::Inclusion::Include) |
void | SetPrefix (const Box &prefix, Scope scope) |
void | SetPrefix (const Box &prefix, Scope scope, threads::Thread *thread) |
void | SetSourcePathTrimRule (const NCString &path, lang::Inclusion includeString=lang::Inclusion::Exclude, int trimOffset=0, lang::Case sensitivity=lang::Case::Ignore, const NString &trimReplacement=NullNString(), lang::Reach reach=lang::Reach::Global, Priorities priority=Priorities::DefaultValues) |
void | SetStartTime (const FILETIME &startTime, const NString &loggerName=nullptr) |
void | SetStartTime (Ticks startTime=time::Ticks(), const NString &loggerName=nullptr) |
void | SetStartTime (time_t startTime, const NString &loggerName=nullptr) |
void | SetVerbosity (const NString &loggerName, Verbosity verbosity, const NString &domain="/", Priorities priority=Priorities::DefaultValues) |
void | SetVerbosity (detail::Logger *logger, Verbosity verbosity, const NString &domain="/", Priorities priority=Priorities::DefaultValues) |
void | State (const NString &domain, Verbosity verbosity, const String &headLine, StateInfo flags=StateInfo::All) |
void | Store (const Box &data, const NString &key, Scope scope=Scope::Global) |
void | Store (const Box &data, Scope scope=Scope::Global) |
template<typename... BoxedObjects> | |
void | Verbose (BoxedObjects &&... logables) |
template<typename... BoxedObjects> | |
void | Warning (BoxedObjects &&... logables) |
|
protected |
|
staticconstexpr |
This is the path for logging to the internal domain. By manipulating this Log Domain's Verbosity, the verbosity of ALox itself can be controlled. For example, with Verbosity.INFO, the 'on the fly' creation of Log Domains are logged, which can be helpful to determine the Lo bg Domains that are created by libraries and larger projects.
The following sub-domains are used by ALox :
Sub-Domain | Description |
---|---|
LGR | Used when Loggers are registered, retrieved or removed from a Lox and when the Verbosity of a Log Domain for a Logger is changed. In addition used with method Lox::SetStartTime. |
DMN | Used when Log Domains are registered (on first use), when Scope Domains are set or removed and when Domain Substitution Rules are set. |
PFX | Used when Prefix Logables are set or removed. |
THR | Used with method Lox::MapThreadName. |
LGD | Used with storing and retrieving Log Data objects. |
In addition, class ALoxReportWriter logs into sub-domain 'REPORT'
.
Constructs a new, empty Lox with the given name . The name is immutable and all Lox objects registered with ALox must be unique. Lower case letters in the name are converted to upper case. The name "Log"
is reserved for the internal default singleton used for debug-logging. In addition, name "GLOBAL"
is not allowed.
If parameter register is true
(the default), static method ALox::Register is invoked and the object will be retrievable with static method ALox::Get. In some situations, such 'registration' may not be wanted.
name | The name of the Lox. Will be copied and converted to upper case. |
doRegister | If true , this object is registered with static class ALox. Optional and defaults to true . |
Definition at line 147 of file lox.inl.
|
inline |
Acquires this Lox and sets the scope information data for the next log.
file | The name of the source code file that the call is placed in. Usually the predefined preprocessor macro FILE is passed here. |
line | The line number within the source code file that the call is placed in. Usually the predefined preprocessor macro LINE is passed here. |
func | The name of the function that the call is placed in. Usually the predefined preprocessor macro func (or FUNCTION) is passed here. |
Definition at line 201 of file lox.inl.
|
inline |
Logs given logables only if the parameter condition is not true
. If executed, Verbosity::Error is used.
The first object provided may be a domain name. All values are passed to EntryDetectDomain. See documentation of this method for information on how to avoid ambiguities in respect to domain names.
If one of the arguments (or a single argument given) is of type Boxes, then the contents of this list is inserted into the list of logables. This allows to collect logables prior to invoking the method.
condition | If false , the Log Statement is executed. |
logables | The list of Logables, optionally including a domain name at the start. |
Definition at line 1137 of file lox.inl.
|
inline |
Removes all local trimming rules set with SetSourcePathTrimRule. If parameter global is set to Inclusion::Include, the global rules are cleared in addition.
Setting parameter allowAutoRule to false
, allows to suppress the creation of an automatic rule based on the executables path.
reach | Denotes whether only local rules are cleared or also global ones. Defaults to Reach::Global. |
allowAutoRule | Determines if an auto rule should be tried to be detected next no appropriate rule is found. |
Definition at line 324 of file lox.inl.
|
static |
This static method creates a console logger. To decide which logger type to choose, configuration variable ALOX_CONSOLE_TYPE is checked. If this variable is not set, then the decision is made as follows:
name | The name of the Logger. Defaults to nullptr, which implies standard logger names defined in the Logger sub-classes. |
Definition at line 2557 of file loxpimpl.cpp.
|
inline |
Returns the internal MonoAllocator used for storing permanent data.
Definition at line 1481 of file lox.inl.
Logs the current list of Logables that previously have been received using GetLogableContainer with the given verbosity .
This method is usually not used directly. Instead, methods Info, Verbose, Warning and Error provide simpler interfaces which take variadic arguments that are collected in a list of boxed objects and then passed to this methods.
Note that the other interface methods accept an "external" list of boxes as a parameter. as well. This means also with these methods it is allowed to collect the logables in an user-specific list first and later pass them to these methods.
Hence, the use of this method is recommended only if the verbosity of a log statement is evaluated only at run-time.
domain | The domain. |
verbosity | The verbosity. |
Definition at line 1003 of file lox.inl.
|
inline |
Logs a list of Logables with the given Verbosity.
If more than one Logable is given and the first one is of string type and comprises a valid domain path, then this first argument is interpreted as the domain name! Valid domain path are strings that consists only of characters of the following set:
'-'
),'_'
) and'/'
).If a first Logable could be misinterpreted as being a domain name, an empty string (the "neutral" domain) has to be added as a first argument. Alternatively, a character which is illegal in respect to domain names could be added to the first argument, for example a simple space at the end of an output string.
verbosity | The verbosity. |
logables | The list of Logables, optionally including a domain name at the start. |
Definition at line 1035 of file lox.inl.
|
inline |
Logs given logables using Verbosity::Error .
The first object provided may be a domain name. All values are passed to EntryDetectDomain. See documentation of this method for information on how to avoid ambiguities in respect to domain names.
If one of the arguments (or a single argument given) is of type Boxes, then the contents of this list is inserted into the list of logables. This allows to collect logables prior to invoking the method.
logables | The list of Logables, optionally including a domain name at the start. |
Definition at line 1115 of file lox.inl.
|
inline |
Returns a reference to a list of boxes to be used for logging. The list is recycled from a previous log operation and cleared. The method may be used to retrieve a container for logables that then are collected until finally logged.
Note that the Lox instance has to be acquired prior to invoking this method and the container returned must be used only while the object is still acquired.
With each recursive acquirement of this object, a different container is returned. This is implemented to allow recursive log calls.
Definition at line 980 of file lox.inl.
|
inline |
Returns the number of logs that have been performed with this Lox. The counter is not used internally other than for providing a unique log number: While each logger attached has a own number, if more than one logger is attached, their numbers may differ due to different log domain settings.
true
if this instance was registered with ALox , false
if not. Definition at line 186 of file lox.inl.
|
inline |
Retrieves an instance of a Logger by its name. This might be useful when access to a Logger is needed to change its configuration.
loggerName | The name of the Logger to search for (case insensitive). |
Definition at line 360 of file lox.inl.
|
inline |
This method collects state information about this lox in a formatted multi-line AString. Parameter flags is a bitwise enum type (operators on elements available).
buf | The target string. |
flags | Bits that define which state information is collected. |
Definition at line 959 of file lox.inl.
|
inline |
Logs a list of Logables only if the parameter condition is true
.
condition | If false , the Log Statement is executed. |
domain | Optional Log Domain which is combined with Scope Domains set for the Scope of invocation. |
verbosity | The verbosity. |
logables | The list of Logables. |
Definition at line 1160 of file lox.inl.
|
inline |
Logs a list of Logables only if the parameter condition is true
.
This overloaded version omits parameter domain . The first logable provided may be a domain name. All values are passed to EntryDetectDomain. See documentation of this method for information on how to avoid ambiguities in respect to domain names.
If one of the arguments (or a single argument given) is of type Boxes, then the contents of this list is inserted into the list of logables. This allows to collect logables prior to invoking the method.
condition | If false , the Log Statement is executed. |
verbosity | The verbosity. |
logables | The list of Logables. |
Definition at line 1190 of file lox.inl.
|
inline |
Logs given logables using Verbosity::Info .
The first object provided may be a domain name. All values are passed to EntryDetectDomain. See documentation of this method for information on how to avoid ambiguities in respect to domain names.
If one of the arguments (or a single argument given) is of type Boxes, then the contents of this list is inserted into the list of logables. This allows to collect logables prior to invoking the method.
logables | The list of Logables, optionally including a domain name at the start. |
Definition at line 1075 of file lox.inl.
|
inline |
Returns the number of loggers attached, which are active in respect to the given combination of verbosity and log domain.
This method may be used to avoid the execution of more complex logging code when such logging would not result in log activity due to the current log level settings.
verbosity | The verbosity to query for activity. |
domain | The log domain. All rules for resolving the effective log domain apply as with normal log statements. Defaults to NullNString. |
Definition at line 1464 of file lox.inl.
|
inline |
This method sets a human readable name to the given thread ID (or current thread) which is optionally included in each log line.
threadName | The name of the thread as it should be displayed in the logs. |
id | (Optional) Parameter providing the thread ID. If omitted, the current thread's ID is used. If given, the associated object of Thread must not be deleted until this method returns. This is a race condition that a using code has do assure. |
Definition at line 830 of file lox.inl.
Overloaded version of Once.
logables | The objects to log (Multiple objects may be provided within container class Boxes.) |
group | The optional name of the statement group . If used, all statements that share the same group name are working on the same counter (according to the scope .) If omitted (or empty or nullptr), the counter is bound to the Scope provided. If omitted and scope is Scope::Global, then the counter is associated exclusively with the single Log Statement itself. |
quantity | The number of logs to be performed. As the name of the method indicates, this defaults to 1 . |
Definition at line 1445 of file lox.inl.
Overloaded version of Once.
logables | The objects to log (Multiple objects may be provided within container class Boxes.) |
group | The optional name of the statement group . If used, all statements that share the same group name are working on the same counter (according to the scope .) If omitted (or empty or nullptr), the counter is bound to the Scope provided. If omitted and scope is Scope::Global, then the counter is associated exclusively with the single Log Statement itself. |
scope | The Scope that the group or counter is bound to. |
quantity | The number of logs to be performed. As the name of the method indicates, this defaults to 1 . |
Definition at line 1352 of file lox.inl.
|
inline |
Overloaded version of Once.
logables | The objects to log (Multiple objects may be provided within container class Boxes.) |
quantity | The number of logs to be performed. As the name of the method indicates, this defaults to 1 . |
Definition at line 1424 of file lox.inl.
Overloaded version of Once.
logables | The objects to log (Multiple objects may be provided within container class Boxes.) |
scope | The Scope that the group or counter is bound to. |
quantity | The number of logs to be performed. As the name of the method indicates, this defaults to 1 . |
Definition at line 1408 of file lox.inl.
|
inline |
Logs given logables once, up to quantity times, or every n-th time. In its simplest overloaded version, the counter is bound to the source code line, hence, only the first execution of this exact Log Statement is executed.
With parameter group , a set of Log Statements that share the same group key, can be grouped and of such set, only the one which is first executed actually logs.
Alternatively, when key is omitted (or nullptr or empty), but a Scope is given with parameter scope , then the counter is associated with the scope.
Finally, parameters key and scope can also be used in combination. The key is then unique in respect to the Scope provided.
Using, none, one or both of the parameters group and scope , among others, the following use cases can be achieved.
When parameter quantity is a negative value, the log statement is executed every n-th time instead n-times. E.g, if quantity is -5
, the first statement is executed and afterwards every fifth invocation.
domain | Optional Log Domain which is combined with Scope Domains set for the Scope of invocation. |
verbosity | The verbosity of the Log Statement (if performed). |
logables | The objects to log (Multiple objects may be provided within container class Boxes.) |
group | The optional name of the statement group . If used, all statements that share the same group name are working on the same counter (according to the scope .) If omitted (or empty or nullptr), the counter is bound to the Scope provided. If omitted and scope is Scope::Global, then the counter is associated exclusively with the single Log Statement itself. |
scope | The Scope that the group or counter is bound to. |
quantity | The number of logs to be performed. As the name of the method indicates, this defaults to 1 . If negative, the first and every "-quantity-th" statement is executed. |
Definition at line 1263 of file lox.inl.
|
inline |
Overloaded version of Once.
domain | Optional Log Domain which is combined with Scope Domains set for the Scope of invocation. |
verbosity | The verbosity of the Log Statement (if performed). |
logables | The objects to log (Multiple objects may be provided within container class Boxes.) |
scope | The Scope that the group or counter is bound to. |
quantity | The number of logs to be performed. As the name of the method indicates, this defaults to 1 . |
Definition at line 1373 of file lox.inl.
|
inline |
Overloaded version of Once.
verbosity | The verbosity of the Log Statement (if performed). |
logables | The objects to log (Multiple objects may be provided within container class Boxes.) |
group | The optional name of the statement group . If used, all statements that share the same group name are working on the same counter (according to the scope .) If omitted (or empty or nullptr), the counter is bound to the Scope provided. If omitted and scope is Scope::Global, then the counter is associated exclusively with the single Log Statement itself. |
quantity | The number of logs to be performed. As the name of the method indicates, this defaults to 1 . |
Definition at line 1313 of file lox.inl.
|
inline |
Overloaded version of Once.
verbosity | The verbosity of the Log Statement (if performed). |
logables | The objects to log (Multiple objects may be provided within container class Boxes.) |
group | The optional name of the statement group . If used, all statements that share the same group name are working on the same counter (according to the scope .) If omitted (or empty or nullptr), the counter is bound to the Scope provided. If omitted and scope is Scope::Global, then the counter is associated exclusively with the single Log Statement itself. |
scope | The Scope that the group or counter is bound to. |
quantity | The number of logs to be performed. As the name of the method indicates, this defaults to 1 . |
Definition at line 1289 of file lox.inl.
Overloaded version of Once.
verbosity | The verbosity of the Log Statement (if performed). |
logables | The objects to log (Multiple objects may be provided within container class Boxes.) |
quantity | The number of logs to be performed. As the name of the method indicates, this defaults to 1 . |
Definition at line 1330 of file lox.inl.
Overloaded version of Once.
verbosity | The verbosity of the Log Statement (if performed). |
logables | The objects to log (Multiple objects may be provided within container class Boxes.) |
scope | The Scope that the group or counter is bound to. |
quantity | The number of logs to be performed. As the name of the method indicates, this defaults to 1 . |
Definition at line 1391 of file lox.inl.
|
inline |
|
inline |
Removes logger named loggerName from this container.
loggerName | The name of the Logger(s) to be removed (case insensitive). |
nullptr
if not found. Definition at line 390 of file lox.inl.
|
inline |
Removes a logger from this container.
logger | The logger to be removed. |
true
, if the Logger was found and removed, false
otherwise. Definition at line 375 of file lox.inl.
|
inline |
This method is used to remove an explicitly given domain path from the list of domain paths set for Scope::ThreadOuter or Scope::ThreadInner.
To remove the most recently added domain path from such thread-related Scope, use one of the overloaded methods SetDomain and provide an empty or nulled value for parameter scopeDomain (the same as how domain paths of other Scopes are removed).
scopeDomain | The domain path to register. |
scope | Either Scope::ThreadOuter or Scope::ThreadInner. With other values, an internal error is logged. |
thread | The thread to set/unset a thread-related Scope Domains for. Defaults to the current thread. |
Definition at line 624 of file lox.inl.
|
inline |
Resets this object. Concretely the following steps are performed:
reInitialze | If called from the destructor false is passed. Defaults to true and must not be set by callers. |
Definition at line 234 of file lox.inl.
Retrieves ALox Log Data, an object type Box which had been stored in a prior call to Store. Using the optional key and scope offer various possibilities to reference such objects.
key | The optional key to the data. If omitted (or empty or nullptr), the data is bound to the Scope provided. If omitted and scope is Scope::Global, then the data is unique to the Lox. |
scope | The Scope that the data is bound to. |
Definition at line 901 of file lox.inl.
scope | The Scope that the data is bound to. |
Definition at line 916 of file lox.inl.
The given scopeDomain becomes the default domain path for given scope . This means, that any subsequent log invocations (from within this same scope) can omit the domain parameter, or if they provide one, this Scope Domain path is prepended. If subsequent log calls specify a domain name with a leading '/' character, then the Scope Domain of the scope is ignored.
Furthermore, if the given scope is an inner scope, outer scopes are prepended to the given scopeDomain when the resulting domain of a log invocation is evaluated. Again, this behavior can be overruled by prepending a leading '/' character to scopeDomain .
To remove a previously set Scope Domain a nulled or empty string has to be passed with parameter scopeDomain . For Scope::ThreadOuter and Scope::ThreadInner, passing an empty or nulled string removes the most recently added domain path. For removing an explicitly named domain path of Scope::ThreadOuter and Scope::ThreadInner use method RemoveThreadDomain.
scopeDomain | The domain path to register. |
scope | The scope that should the given domain be registered for. Available Scope definitions are platform/language dependent. |
Definition at line 514 of file lox.inl.
|
inline |
This overloaded version of SetDomain is applicable only for Scope::ThreadOuter and Scope::ThreadInner and allows to specify the thread that the setting should be associated with.
If scopeDomain is nullptr or empty, the most recently added domain path is removed. For removing an explicitly named domain associated with a thread use method RemoveThreadDomain.
scopeDomain | The domain path to register. |
scope | Either Scope::ThreadOuter or Scope::ThreadInner. With other values, an internal error is logged. |
thread | The thread to set/unset a thread-related Scope Domains for. |
Definition at line 534 of file lox.inl.
Adds a Domain Substitution Rule. Domain Substitution is performed as a last step when evaluating the domain path of a Log Statement, taking Scope Domains and the optional parameter domain of the statement into account.
Wildcards
Parameter domainPath supports 'wildcard' character '*'
at its beginning and at its end (or both). This allows to have four types of rules:
*
at the end of domainPath )*
at the start of domainPath )*
at both, start and the end of domainPath )Only minimal checks are performed, e.g. if an exact match is requested, but domainPath does not start with character '/'
. In this and some other cases, the rule is not stored and an internal warning is logged. Further checks, for example for illegal domain path characters are not performed (those will be eliminated when the resulting domain path is to be created internally).
Circular Dependencies
If the given rules have circular dependencies, only a limited number (ten) replacements are performed. If this number of replacements for one Log Statement is exceeded, an internal warning message is logged. This is done only once over the life-time of a Logger.
Application of Rules
Rules are applied in the order of their definition. After all rules have been applied this is repeated as long as at least one rule matched (up to ten times).
Deletion of Rules To delete a rule, invoke the method with same parameter domainPath and a 'nulled' or empty string for parameter replacement . To delete all rules, invoke the method with parameter domainPath 'nulled' or empty.
Final remarks Domain substitution is useful to permanently change ('redirect') domain paths of 3rd party code (e.g. libraries using ALox ) or log statements that must not be changed for other reasons. It is advised to not 'overuse' this feature, as side effects are inherent to the concept of Domain Substitution. For example, an unwanted side effect might be that Prefix Logables are not applicable to the substituted domain, while other Prefix Logables are bound to the resulting domain.
For Lox objects that should be protected of external manipulation, it is advisable, to remove all Domain Substitution Rules right after the Lox was created by invoking this method with a nulled value for parameter domainPath . The reason is, that otherwise, through configuration files or command line parameters, domains of the Lox can be substituted and then the resulting domains Verbosities be overwritten using further configuration variables. Any prioritized 'internal' setting of Verbosities this way could be circumvented!
For more information consult the chapter 15 Log Domain Substitution of the Programmer's Manual.
domainPath | The path to search. Has to start with either '/' or '*' . |
replacement | The replacement path. |
Definition at line 596 of file lox.inl.
|
inline |
The given prefix becomes a Prefix Logable associated to the given Log Domain. Prefix Logables associated with the Log Domain are added to the list of Logables right before the main Logable of the Log Statement itself. Multiple Prefix Logables can be added per Log Domain.
To remove the most recently added Prefix Logable associated with a Log Domain, nullptr
has to be passed with parameter prefix .
""
which addresses the domain evaluated for the current scope.prefix | The Prefix Logable to set. |
domain | The domain path. Defaults to nullptr , resulting in evaluated Scope Domain path. |
otherPLs | If set to Inclusion::Exclude , scope-related Prefix Logables are ignored and only domain-related Prefix Logables are passed to the Loggers.Defaults to Inclusion::Include . |
Definition at line 753 of file lox.inl.
The given prefix becomes a Prefix Logable provided to loggers with each log statement executed within the given scope . The list of objects received by a logger is sorted from outer scope to inner scope. The logable of the Log Statement itself, is the last in the list, except one or more Prefix Logables of Scope::ThreadInner are set. Those are (similar to how this Scope is used with Scope Domains) appended to the end of the list.
To remove a previously set Prefix Logable, nullptr
has to be passed with parameter prefix . For Scope::ThreadOuter and Scope::ThreadInner, passing nullptr
(respectively with the overloaded method accepting string messages, a nulled string) removes the most recently added Prefix Logable.
std::reference_wrapper<AString>
.prefix | The Prefix Logable to set. |
scope | The scope that should the given domain be registered for. Available Scope definitions are platform/language dependent. |
Definition at line 692 of file lox.inl.
|
inline |
This overloaded version of SetPrefix is applicable only for Scope::ThreadOuter and Scope::ThreadInner and allows to specify the thread that the setting should be associated with.
If scopeDomain is nullptr or empty, the most recently added Prefix Logable is removed.
prefix | The Prefix Logable to set. |
scope | Either Scope::ThreadOuter or Scope::ThreadInner. With other values, an internal error is logged. |
thread | The thread to set/unset a thread-related Scope Domains for. |
Definition at line 711 of file lox.inl.
|
inline |
Adds path to an internal list of sub-strings that are used to trim the path of a source file name. Trimmed paths are used for Scope mechanisms and can be logged (e.g. with meta information of class TextLogger.
By default such setting affects all instances of class Lox, not only this instance. This can be altered using parameter global . one other The given trim information can either
If given path starts with character '*'
, the rest of the string is searched within source paths. Otherwise, it is checked if a source path starts with the given path.
Parameter trimReplacement optionally provides a replacement string for the trimmed path. This can be used for example to provide the right absolute path for an IDE to find source files of a library.
Parameter includeString determines if the searched sub-string should be included in the resulting source path or not. In addition, parameter trimOffset , which can be negative or positive, is added to the position of trimming. This can be used to increase the length of the search path, and then cut only a portion of what was searched for.
Finally, parameter sensitivity determines whether the match is performed case sensitive or not. It defaults to non-sensitive, for convenience and for the fact that for example Microsoft C++ compiler's preprocessor passes lower case path-strings!
'/'
, then characters '\'
found in parameters path and trimReplacement are replaced by '\'
and vice versa. This allows to specify paths and sub-strings thereof in a platform independent way.Inclusion::Include
) is not protected by a mutex
against concurrent access. Therefore, global rules have to be either at bootstrap of a process, before threads are created, or such creation has to 'manually' be protected by locking all existing instances of this class!path | The path to search for. If not starting with '*' , a prefix is searched. |
includeString | Determines if path should be included in the trimmed path or not. Optional and defaults to Inclusion::Exclude. |
trimOffset | Adjusts the portion of path that is trimmed. Optional and defaults to 0 . |
sensitivity | Determines if the comparison of path with a source file's path is performed case sensitive or not. Optional and defaults to Case::Ignore. |
trimReplacement | Replacement string for trimmed portion of the path. Optional and defaults to NullString(). |
reach | Denotes whether the rule is applied locally (to this Lox only) or applies to all instances of class Lox. Defaults to Reach::Global. |
priority | The priority of the setting. Defaults to Priorities::DefaultValues. |
Definition at line 295 of file lox.inl.
|
inline |
Converts the given startTime and invokes::SetStartTime(Ticks,const NString&).
startTime | The new start time in system specific time unit. |
loggerName | The name of the Logger whose start time is to be set (case insensitive). Defaults to empty string, which indicates that all loggers are to be affected. |
Definition at line 812 of file lox.inl.
|
inline |
This method is used reset (or to explicitly set) the start time of one or all logger(s). The only impact is the output of time differences in the log lines. Hence, this method is useful to reset them and see some absolute time values when doing basic performance tests using the Logger.
startTime | Optional parameter with the new start time. Defaults to current time if omitted. |
loggerName | The name of the Logger(s) whose start time is to be set (case insensitive). Defaults to nullptr, which indicates that all loggers are to be affected. |
Definition at line 776 of file lox.inl.
|
inline |
Converts the given startTime and invokes SetStartTime(Ticks,const NString&).
startTime | The new start time in system specific time unit. |
loggerName | The name of the Logger whose start time is to be set (case insensitive). Defaults to empty string, which indicates that all loggers are to be affected. |
Definition at line 793 of file lox.inl.
|
inline |
Same as SetVerbosity but addressing the Logger to manipulate by its name.
This method may only be used after a Logger was once 'registered' with this Lox using SetVerbosity.
loggerName | The logger to be to be affected, identified by its name (case insensitive). |
verbosity | The 'level of verboseness' to be set. |
domain | The parent (start) domain to be set. The use of absolute paths starting with '/' are recommended. Defaults to root domain "/". |
priority | The priority of the setting. Defaults to Priorities::DefaultValues. |
Definition at line 477 of file lox.inl.
|
inline |
Sets the Verbosity of the Log Domain which is evaluated from parameter domain and applicable Scope Domains. The verbosity given is set recursively for all sub-domains.
With the first invocation of this method for a distinct logger , this Logger is registered with this Lox. In this case, prior to setting the given Verbosity for the evaluated sub-domain, the Verbosity for all domains is set to Verbosity::Off.
To deregister a Logger with a Lox, use method RemoveLogger. To 'disable' a Logger, invoke this method with parameters verbosity equaling to Verbosity::Off and domain to "/"
.
Optional parameter priority defaults to Priorities::DefaultValues, which is a lower priority than those of the standard plug-ins of external configuration data. Therefore, external configuration by default 'overwrite' settings made from 'within the source code', which simply means by invoking this method.
The parameter can be provided for two main reasons:
Config::PriorityOf(Priorities::DefaultValues) + 1
, then this sub-domain will not be affected by future invocations of this method with standard-priority given.For more information on how to use external configuration variables with priority and on protecting verbosity settings, consult the ALib Module ALox - Programmer's Manual.
'/'
, which suppresses the concatenation of Scope Domains. '/'
, while with other methods of this class, it defaults to an empty string. logger | The logger to be to be affected (case insensitive). |
verbosity | The 'level of verboseness' to be set. |
domain | The parent (start) domain to be set. The use of absolute paths starting with '/' are recommended. Defaults to root domain "/". |
priority | The priority of the setting. Defaults to Priorities::DefaultValues. |
Definition at line 454 of file lox.inl.
|
inline |
This method logs the current configuration of this Lox and its encapsulated objects. It uses method GetState to assemble the logable string.
domain | Optional Log Domain which is combined with Scope Domains set for the Scope of invocation. |
verbosity | The verbosity. |
headLine | If given, a separated headline will be logged at first place. |
flags | Flag bits that define which state information is logged. |
Definition at line 938 of file lox.inl.
Stores data encapsulated in an object of class Box which can be retrieved back by invoking Retrieve. Using the optional key and scope offer various possibilities to reference this data later.
To remove data from the store, pass nullptr
with parameter data .
new
) may be passed!data | The data object to store. If nullptr , currently stored data will be removed. In C++, has to be heap allocated and will be deleted by this Lox when overwritten or this lox is deleted. |
key | The optional key to the data. If omitted (or empty or nullptr), the data is bound to the Scope provided. If omitted and scope is Scope::Global, then the data is unique to the Lox. |
scope | The Scope that the data is bound to. |
Definition at line 862 of file lox.inl.
Overloaded version of Store(const Box&,const String&,Scope,int) "Store" which omits parameter key .
data | The data object to store. In C++, has to be heap allocated and will be deleted by this Lox when overwritten or this lox is deleted. |
scope | The Scope that the data is bound to. |
Definition at line 875 of file lox.inl.
|
inline |
Logs given logables using Verbosity::Verbose .
The first object provided may be a domain name. All values are passed to EntryDetectDomain. See documentation of this method for information on how to avoid ambiguities in respect to domain names.
If one of the arguments (or a single argument given) is of type Boxes, then the contents of this list is inserted into the list of logables. This allows to collect logables prior to invoking the method.
logables | The list of Logables, optionally including a domain name at the start. |
Definition at line 1055 of file lox.inl.
|
inline |
Logs given logables using Verbosity::Warning .
The first object provided may be a domain name. All values are passed to EntryDetectDomain. See documentation of this method for information on how to avoid ambiguities in respect to domain names.
If one of the arguments (or a single argument given) is of type Boxes, then the contents of this list is inserted into the list of logables. This allows to collect logables prior to invoking the method.
logables | The list of Logables, optionally including a domain name at the start. |
Definition at line 1095 of file lox.inl.