Encapsulates information of the caller that can be collected. This is platform specific, in this case, C++. What we receive from the C++ preprocessor, is the source file name of the calling code, the line number within the source file name and the name of the method the call is placed in. E.g., wee do not get the class name of the object or even its instance.
The method has a list of interface functions that gets such source information and some derived variants of it. In addition, thread and timer information is stored and managed.
As far as possible, 'lazy' techniques come to practice with this class. This means, only the things that are queried in-between to invocations of method Set are calculated.
class Lox
Definition at line 60 of file scopeinfo.inl.
Inner Type Index: | |
struct | Scope |
struct | SourceFile |
struct | SourcePathTrimRule |
Public Type Index: | |
using | ThreadDictionary = HashMap<threads::ThreadID, String32> |
Public Static Field Index: | |
static ALIB_API int | DefaultCacheSize = 5 |
Public Field Index: | |
NString | loxName |
Public Method Index: | |
ALIB_API | ScopeInfo (const NString &name, MonoAllocator *allocator, config::Variable &tempVar) |
const NString | GetFileName () |
const NString | GetFileNameWithoutExtension () |
const NString | GetFullPath () |
int | GetLineNumber () |
const NString | GetLoxName () |
const NCString | GetMethod () |
const NCString & | GetOrigFile () |
threads::ThreadID | GetThreadID () |
const alib::String & | GetThreadNameAndID (threads::ThreadID *id) |
Ticks | GetTimeStamp () |
void | GetTrimmedPath (AString &target) |
void | Release () |
ALIB_API void | Set (const NCString &source, int lineNumber, const NCString &method, threads::Thread *thread) |
ALIB_API void | SetSourcePathTrimRule (const NCString &path, lang::Inclusion includeString, int trimOffset, lang::Case sensitivity, const NString &trimReplacement, lang::Reach reach, Priorities priority) |
using ThreadDictionary = HashMap<threads::ThreadID, String32> |
A std::map we use to translate thread IDs to thread names
Definition at line 74 of file scopeinfo.inl.
|
protected |
The current depth of recursive invocations.
Definition at line 216 of file scopeinfo.inl.
|
protected |
If true, next time a source path can not be trimmed successfully with custom trim information provided with Lox::SetSourcePathTrimRule some trim information is automatically created by comparing such source file's path with the path of the executable of the current process.
Definition at line 122 of file scopeinfo.inl.
|
protected |
An array of source files. Its size is dependent on static field DefaultCacheSize.
Definition at line 190 of file scopeinfo.inl.
|
protected |
The 'timestamp' used to identify the LRU entry. Incremented, whenever a different source file is evaluated.
Definition at line 181 of file scopeinfo.inl.
|
protected |
The number of source file path and corresponding, evaluated derived values. Determined in the constructor by reading static field DefaultCacheSize.
Definition at line 187 of file scopeinfo.inl.
|
static |
The number of source file path and corresponding, evaluated derived values. This might be modified, prior to creating any object of class Lox.
Defaults to 5.
Definition at line 83 of file scopeinfo.inl.
|
staticprotected |
List of trim definitions for portions of source paths to be ignored.
Definition at line 106 of file scopeinfo.inl.
|
staticprotected |
Flag to determine if global rules have been read from config already.
Definition at line 113 of file scopeinfo.inl.
|
protected |
The last source file used. This is tried first with next invocation. If it does not match, the cache is searched for another matching one.
Definition at line 220 of file scopeinfo.inl.
|
protected |
List of trim definitions for portions of source paths to be ignored.
Definition at line 109 of file scopeinfo.inl.
NString loxName |
The name of the Lox we are attached to.
Definition at line 86 of file scopeinfo.inl.
A stack of scopes (allows recursive calls/nested logging).
Definition at line 213 of file scopeinfo.inl.
|
protected |
The thread passed with Set.
Definition at line 127 of file scopeinfo.inl.
|
protected |
Dictionary to translate thread IDs into something maybe nicer/shorter. The dictionary may be filled by the user of the library using Lox.MapThreadName .
Definition at line 136 of file scopeinfo.inl.
|
protected |
The name of the thread that executed the log.
Definition at line 130 of file scopeinfo.inl.
ScopeInfo | ( | const NString & | name, |
MonoAllocator * | allocator, | ||
config::Variable & | tempVar ) |
Constructs a scope info.
name | The name of the Lox that this object belongs to. Will be converted to upper case. |
allocator | The monotonic allocator of "our" Lox, used for long-term allocations |
tempVar | A temporary variable for internal use. |
Definition at line 54 of file scopeinfo.cpp.
|
inline |
Receives the source file name excluding the path (usually provided by the preprocessor).
Definition at line 356 of file scopeinfo.inl.
|
inline |
Receives the source file name excluding the path and without an extension (usually provided by the preprocessor).
Definition at line 380 of file scopeinfo.inl.
|
inline |
Receives the path of the source file (not trimmed, see GetTrimmedPath).
Definition at line 322 of file scopeinfo.inl.
|
inline |
Receives the source file line number (usually provided by the preprocessor).
Definition at line 407 of file scopeinfo.inl.
|
inline |
Receives the name of the Lox we are belonging to (this is a 1:1 relationship).
Definition at line 303 of file scopeinfo.inl.
|
inline |
Receives the method name (usually provided by the preprocessor).
Definition at line 398 of file scopeinfo.inl.
|
inline |
Receives the original filename and path of the source file (usually provided by the preprocessor).
Definition at line 313 of file scopeinfo.inl.
|
inlineprotected |
Gets position of path/filename separator. This is evaluated only once after an invocation of Set.
Definition at line 481 of file scopeinfo.inl.
|
inline |
Receives the thread ID of the caller.
Definition at line 426 of file scopeinfo.inl.
|
inline |
Receives information about the thread that the current call was invoked with.
id | Output parameter receiving the ALib thread ID. If nullptr, it will be ignored. |
Definition at line 440 of file scopeinfo.inl.
|
inline |
The timestamp of the last invocation of Set.
Definition at line 416 of file scopeinfo.inl.
|
inline |
Writes the path of the source file, trimmed according to trim-information provided with SetSourcePathTrimRule or detected according to AutoDetectTrimableSourcePath.
target | The target string to append the trimmed path to. |
Definition at line 342 of file scopeinfo.inl.
|
inline |
void Set | ( | const NCString & | source, |
int | lineNumber, | ||
const NCString & | method, | ||
threads::Thread * | thread ) |
Stores C++ specific caller parameters and some other values like the time stamp. Also, flags thread information as not received, yet. Counts the recursion counter up.
source | Name, including path, of the source code file of the actual log invocation (FILE). |
lineNumber | Line number within the source code file of the actual log invocation (LINE). |
method | Name of method or function of the actual log invocation (mostly func/ FUNCTION). |
thread | The thread. If nullptr , it will be determined if needed. |
Definition at line 132 of file scopeinfo.cpp.
void SetSourcePathTrimRule | ( | const NCString & | path, |
lang::Inclusion | includeString, | ||
int | trimOffset, | ||
lang::Case | sensitivity, | ||
const NString & | trimReplacement, | ||
lang::Reach | reach, | ||
Priorities | priority ) |
Does the job for Lox::SetSourcePathTrimRule and Lox::ClearSourcePathTrimRules.
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. |
trimOffset | Adjusts the portion of path that is trimmed. 999999 to clear! |
sensitivity | Determines if the comparison of path with a source file's path is performed case sensitive or not. |
trimReplacement | Replacement string for trimmed portion of the path. |
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. |
Definition at line 188 of file scopeinfo.cpp.
|
protected |
Tries to trim the source file's path. Sets variable SourceFile::trimmedPath to either the successfully trimmed path or to the non-trimmed one. This way, it is executed only once, at it is 'lazily' invoked by GetTrimmedPath()
Definition at line 255 of file scopeinfo.cpp.