clutchlog 0.17
|
The single class which holds everything. More...
#include <clutchlog.h>
The single class which holds everything.
This is a Singleton class.
Definition at line 188 of file clutchlog.h.
Public Member Functions | |
Configuration accessors | |
void | format (const std::string &format) |
Set the template string. More... | |
std::string | format () const |
Get the template string. More... | |
void | format_comment (const std::string &format) |
Set the template string for dumps. More... | |
std::string | format_comment () const |
Get the template string for dumps. More... | |
void | out (std::ostream &out) |
Set the output stream on which to print. More... | |
std::ostream & | out () |
Get the output stream on which to print. More... | |
void | filehash_styles (std::vector< fmt > styles) |
Set the candidate styles for value-dependant file name formatting. More... | |
void | funchash_styles (std::vector< fmt > styles) |
Set the candidate styles for value-dependant function name formatting. More... | |
void | depth_styles (std::vector< fmt > styles) |
Set the styles for value-dependant depth formatting. More... | |
void | threshold (level l) |
Set the log level (below which logs are not printed) with an identifier. More... | |
void | threshold (const std::string &l) |
Set the log level (below which logs are not printed) with a string. More... | |
level | threshold () const |
Get the log level below which logs are not printed. More... | |
const std::map< std::string, level > & | levels () const |
Get the map of available log levels string representations toward their identifier. */. More... | |
level | level_of (const std::string name) |
Return the log level tag corresponding to the given pre-configured name. More... | |
void | file (std::string file) |
Set the regular expression filtering the file location. More... | |
void | func (std::string func) |
Set the regular expression filtering the function location. More... | |
void | line (std::string line) |
Set the regular expression filtering the line location. More... | |
void | location (const std::string &in_file, const std::string &in_function=".*", const std::string &in_line=".*") |
Set the regular expressions filtering the location. More... | |
template<class ... FMT> | |
void | style (level stage, FMT... styles) |
Set the style (color and typo) of the given log level. More... | |
void | style (level stage, fmt style) |
Set the style (color and typo) of the given log level, passing a fmt instance. More... | |
fmt | style (level stage) const |
Get the configured fmt instance of the given log level. More... | |
void | filename (filename f) |
Sets the file naming scheme. */. More... | |
Low-level API | |
scope_t | locate (const level &stage, const std::string &file, const std::string &func, const size_t line) const |
Gather information on the current location of the call. More... | |
std::string | replace (const std::string &form, const std::string &mark, const std::string &tag) const |
Replace mark by tag in form . More... | |
std::string | replace (const std::string &form, const std::string &mark, const size_t tag) const |
Replace mark by tag in form , converting tag to its string representation first. More... | |
std::string | format (std::string row, const std::string &what, const level &stage, const std::string &file, const std::string &func, const size_t line) const |
Substitute all tags in the format string with the corresponding information and apply the style corresponding to the log level. More... | |
void | log (const level &stage, const std::string &what, const std::string &file, const std::string &func, const size_t line, const size_t depth_delta=0) const |
Print a log message IF the location matches the given one. More... | |
template<class In > | |
void | dump (const level &stage, const In container_begin, const In container_end, const std::string &file, const std::string &func, const size_t line, const std::string &filename_template="dump_{n}.dat", const std::string sep=dump_default_sep) const |
Dump a serializable container after a comment line with log information. More... | |
Static Protected Attributes | |
Default configuration members | |
static std::string | default_format = CLUTCHLOG_DEFAULT_FORMAT |
Default format of the messages. More... | |
static std::string | dump_default_format = CLUTCHDUMP_DEFAULT_FORMAT |
Default format of the comment line in file dump. More... | |
static std::string | dump_default_sep = CLUTCHDUMP_DEFAULT_SEP |
Default item separator for dump. More... | |
static std::string | default_depth_mark = CLUTCHLOG_DEFAULT_DEPTH_MARK |
Default mark for stack depth. More... | |
static unsigned int | default_strip_calls = CLUTCHLOG_STRIP_CALLS |
Number of call stack levels to remove from depth display by default. More... | |
static char | default_hfill_char = CLUTCHLOG_DEFAULT_HFILL_MARK |
Default character used as a filling for right-align the right part of messages with "{hfill}". More... | |
static size_t | default_hfill_max = CLUTCHLOG_DEFAULT_HFILL_MAX |
Default maximum width (number of characters) for which to fill for right-aligning the right part of messages (using "{hfill}"). More... | |
static size_t | default_hfill_min = CLUTCHLOG_DEFAULT_HFILL_MIN |
Default minimum width (number of characters) at which to fill for right-aligning the right part of messages (using "{hfill}"). More... | |
Classes | |
class | fmt |
Color and style formatter for ANSI terminal escape sequences. More... | |
struct | scope_t |
Structure holding a location matching. More... | |
High-level API | |
enum | level { critical =0 , error =1 , warning =2 , progress =3 , note =4 , info =5 , debug =6 , xdebug =7 } |
Available log levels. More... | |
enum | filename { path , base , dir , dirbase , stem , dirstem } |
Available filename rendering methods. More... | |
static clutchlog & | logger () |
Get the logger instance. More... | |
Internal details | |
size_t | _strip_calls |
Current number of call stack levels to remove from depth display. More... | |
const std::map< level, std::string > | _level_word |
Dictionary of level identifier to their string representation. More... | |
std::map< std::string, level > | _word_level |
Dictionary of level string to their identifier. More... | |
std::map< level, std::string > | _level_short |
dictionary of level identifier to their 4-letters representation. More... | |
std::map< level, fmt > | _level_fmt |
Dictionary of level identifier to their format. More... | |
std::string | _format_log |
Current format of the standard output. More... | |
std::string | _format_dump |
Current format of the file output. More... | |
std::ostream * | _out |
Standard output. More... | |
level | _stage |
Current log level. More... | |
std::regex | _in_file |
Current file location filter. More... | |
std::regex | _in_func |
Current function location filter. More... | |
std::regex | _in_line |
Current line location filter. More... | |
std::vector< fmt > | _filehash_fmts |
List of candidate format objects for value-dependant file name styling. More... | |
std::vector< fmt > | _funchash_fmts |
List of candidate format objects for value-dependant function name styling. More... | |
filename | _filename |
Filename rendering method. More... | |
clutchlog (clutchlog const &)=delete | |
void | operator= (clutchlog const &)=delete |
clutchlog () | |
|
inlineprivate |
Definition at line 850 of file clutchlog.h.
|
inlinestatic |
Get the logger instance.
Definition at line 307 of file clutchlog.h.
|
inline |
Set the template string.
Definition at line 986 of file clutchlog.h.
References _format_log, and format().
Referenced by format().
|
inline |
Get the template string.
Definition at line 988 of file clutchlog.h.
References _format_log.
Referenced by dump(), format_comment(), and log().
|
inline |
Set the template string for dumps.
Definition at line 991 of file clutchlog.h.
References _format_dump, and format().
|
inline |
Get the template string for dumps.
Definition at line 993 of file clutchlog.h.
References _format_dump.
|
inline |
Set the output stream on which to print.
Definition at line 996 of file clutchlog.h.
Referenced by out().
|
inline |
Get the output stream on which to print.
Definition at line 998 of file clutchlog.h.
References _out.
|
inline |
Set the candidate styles for value-dependant file name formatting.
Style will be chosen based on the hash value of the filename among the candidate ones.
See the {filehash_fmt}
template tag.
Definition at line 1047 of file clutchlog.h.
References _filehash_fmts.
|
inline |
Set the candidate styles for value-dependant function name formatting.
Style will be chosen based on the hash value of the filename among the candidate ones.
See the {funchash_fmt}
template tag.
Definition at line 1055 of file clutchlog.h.
References _funchash_fmts.
|
inline |
Set the styles for value-dependant depth formatting.
The given list should be ordered, styles will be applied for the corresponding depth level. If the actual depth is larger than the number of styles, the last one is used.
See the {depth_fmt}
template tag.
Definition at line 1064 of file clutchlog.h.
|
inline |
Set the log level (below which logs are not printed) with an identifier.
Definition at line 1067 of file clutchlog.h.
References _stage.
|
inline |
Set the log level (below which logs are not printed) with a string.
Definition at line 1069 of file clutchlog.h.
References _stage, and level_of().
|
inline |
Get the log level below which logs are not printed.
Definition at line 1071 of file clutchlog.h.
References _stage.
|
inline |
Get the map of available log levels string representations toward their identifier. */.
Definition at line 1073 of file clutchlog.h.
References _word_level.
|
inline |
Return the log level tag corresponding to the given pre-configured name.
_level_word
. Definition at line 1079 of file clutchlog.h.
References _word_level.
Referenced by threshold().
|
inline |
Set the regular expression filtering the file location.
Definition at line 1090 of file clutchlog.h.
References _in_file, and file().
Referenced by dump(), file(), format(), locate(), location(), and log().
|
inline |
Set the regular expression filtering the function location.
Definition at line 1092 of file clutchlog.h.
References _in_func, and func().
Referenced by dump(), format(), func(), locate(), location(), and log().
|
inline |
Set the regular expression filtering the line location.
Definition at line 1094 of file clutchlog.h.
References _in_line, and line().
Referenced by dump(), format(), line(), locate(), location(), and log().
|
inline |
Set the regular expressions filtering the location.
Definition at line 1097 of file clutchlog.h.
|
inline |
Set the style (color and typo) of the given log level.
This version accept style arguments as if they were passed to clutchlog::fmt
.
Definition at line 1113 of file clutchlog.h.
References style().
Referenced by style().
Set the style (color and typo) of the given log level, passing a fmt
instance.
Definition at line 1115 of file clutchlog.h.
References _level_fmt, and style().
Referenced by style().
Get the configured fmt instance of the given log level.
Definition at line 1117 of file clutchlog.h.
References _level_fmt.
|
inline |
Sets the file naming scheme. */.
Definition at line 1120 of file clutchlog.h.
References _filename.
|
inline |
Gather information on the current location of the call.
Definition at line 1154 of file clutchlog.h.
References _in_file, _in_func, _in_line, _stage, _strip_calls, file(), func(), line(), clutchlog::scope_t::matches, clutchlog::scope_t::stage, and clutchlog::scope_t::there.
|
inline |
|
inline |
Replace mark
by tag
in form
, converting tag to its string representation first.
Definition at line 1270 of file clutchlog.h.
References replace().
|
inline |
Substitute all tags in the format string with the corresponding information and apply the style corresponding to the log level.
Definition at line 1281 of file clutchlog.h.
References _filehash_fmts, _filename, _funchash_fmts, _level_fmt, _level_short, _level_word, _strip_calls, file(), func(), line(), and replace().
|
inline |
Print a log message IF the location matches the given one.
Definition at line 1413 of file clutchlog.h.
References _format_log, _out, file(), format(), func(), line(), locate(), and clutchlog::scope_t::matches.
|
inline |
Dump a serializable container after a comment line with log information.
Definition at line 1438 of file clutchlog.h.
References _format_dump, file(), format(), func(), line(), locate(), clutchlog::scope_t::matches, and replace().
|
inlinestaticprotected |
Default format of the messages.
Definition at line 224 of file clutchlog.h.
|
inlinestaticprotected |
Default format of the comment line in file dump.
Definition at line 246 of file clutchlog.h.
|
inlinestaticprotected |
Default item separator for dump.
Definition at line 253 of file clutchlog.h.
|
inlinestaticprotected |
Default mark for stack depth.
Definition at line 260 of file clutchlog.h.
|
inlinestaticprotected |
Number of call stack levels to remove from depth display by default.
Definition at line 267 of file clutchlog.h.
|
inlinestaticprotected |
Default character used as a filling for right-align the right part of messages with "{hfill}".
Definition at line 274 of file clutchlog.h.
|
inlinestaticprotected |
Default maximum width (number of characters) for which to fill for right-aligning the right part of messages (using "{hfill}").
Definition at line 286 of file clutchlog.h.
|
inlinestaticprotected |
Default minimum width (number of characters) at which to fill for right-aligning the right part of messages (using "{hfill}").
Definition at line 288 of file clutchlog.h.
|
protected |
Current number of call stack levels to remove from depth display.
Definition at line 919 of file clutchlog.h.
|
protected |
Dictionary of level identifier to their string representation.
Definition at line 921 of file clutchlog.h.
Referenced by format().
|
protected |
Dictionary of level string to their identifier.
Definition at line 923 of file clutchlog.h.
Referenced by level_of(), and levels().
|
protected |
dictionary of level identifier to their 4-letters representation.
Definition at line 925 of file clutchlog.h.
Referenced by format().
Dictionary of level identifier to their format.
Definition at line 927 of file clutchlog.h.
|
protected |
Current format of the standard output.
Definition at line 929 of file clutchlog.h.
|
protected |
Current format of the file output.
Definition at line 931 of file clutchlog.h.
Referenced by dump(), and format_comment().
|
protected |
|
protected |
Current log level.
Definition at line 951 of file clutchlog.h.
Referenced by locate(), and threshold().
|
protected |
Current file location filter.
Definition at line 953 of file clutchlog.h.
|
protected |
Current function location filter.
Definition at line 955 of file clutchlog.h.
|
protected |
Current line location filter.
Definition at line 957 of file clutchlog.h.
|
protected |
List of candidate format objects for value-dependant file name styling.
Definition at line 960 of file clutchlog.h.
Referenced by filehash_styles(), and format().
|
protected |
List of candidate format objects for value-dependant function name styling.
Definition at line 962 of file clutchlog.h.
Referenced by format(), and funchash_styles().
|
protected |
Filename rendering method.
Definition at line 977 of file clutchlog.h.
Referenced by filename(), and format().
enum clutchlog::level |
Available log levels.
Definition at line 314 of file clutchlog.h.
enum clutchlog::filename |
Available filename rendering methods.
Definition at line 317 of file clutchlog.h.