11 #define Log_debug Log::inst() << log::level::debug << "[" << log::srcFilename(__FILE__) << ":" << __LINE__ << "] "
45 vector<tuple<const Level*, String>>
records;
79 typedef unordered_map<Id, log::Sink::Ptr>
SinkMap;
100 const LevelGraph&
levels()
const {
return _levelGraph; }
105 const SinkMap&
sinks()
const {
return _sinks; }
115 void filter(
const Id& sink,
const vector<const log::Level*>& includes,
bool includeDeps =
true,
116 const vector<const log::Level*>& excludes = {},
bool excludeDeps =
true);
126 typedef unordered_map<Id, std::set<Id>> FilterMap;
128 void push(
const String& record);
130 LevelGraph _levelGraph;
Formats record to a file stream.
Definition: Log.h:59
~RecordStream()
Definition: Log.h:86
Logger.
Definition: Log.h:75
A thread lock where the lock is acquired through a busy wait loop.
Definition: Spin.h:17
Combined intrusive/non-intrusive smart pointer. Can reference and share any object automatically...
Definition: SharedPtr.h:175
virtual void operator()(const Level &level, const String &record)=0
Level info(nullptr,"info")
General information.
Definition: Log.h:25
RecordStream(Log &log, const log::Level &level)
Definition: Log.h:84
FileSink(String filepath)
Definition: Log.cpp:52
void removeLevel(const log::Level &level)
Definition: Log.cpp:97
std::ofstream os
Definition: Log.h:67
Level debug(nullptr,"debug")
Low-level information for debugging purposes.
Definition: Log.h:26
const LevelGraph & levels() const
Definition: Log.h:100
static mt_global(Log, inst,)
Get singleton.
SharedPtr< BufferSink > Ptr
Definition: Log.h:42
ostream & os
Definition: Log.h:55
StreamSink(ostream &os)
Definition: Log.h:53
virtual void operator()(const Level &level, const String &record)
Definition: Log.cpp:41
String substr(szt pos=0, szt len=npos) const
Definition: String.h:104
Reference-counted object for intrusive shared pointers.
Definition: SharedPtr.h:93
SpinLock::Scoped lock()
Acquire lock to synchronize output to sinks, other loggers should call this before outputting to the ...
Definition: Log.h:123
Formats record to a stream.
Definition: Log.h:49
Captures records in a buffer.
Definition: Log.h:40
void removeSink(const Id &name)
Definition: Log.cpp:107
Level critical(nullptr,"critical")
Information describing a critical problem that has occurred.
Definition: Log.h:22
Level error(nullptr,"error")
Information describing a major problem that has occurred.
Definition: Log.h:23
virtual void operator()(const Level &level, const String &record)
Definition: Log.cpp:46
Level warning(nullptr,"warning")
Information describing a minor problem that has occurred.
Definition: Log.h:24
SharedPtr< StreamSink > Ptr
Definition: Log.h:51
void clearFilter(const Id &sink)
Definition: Log.cpp:133
vector< tuple< const Level *, String > > records
Definition: Log.h:45
Dependency node for insertion into graph.
Definition: Dep.h:14
Unicode UTF-16 string class, wrapper around std::u16string.
Definition: String.h:23
void addSink(const Id &name, const log::Sink::Ptr &sink)
Add a sink to receive records.
Definition: Log.cpp:102
~FileSink()
Definition: Log.cpp:61
Log()
Create logger with default levels and a standard streams sinks ("stdout" and "stderr") ...
Definition: Log.cpp:75
SpinLock::Scoped lock
Definition: Log.h:88
size_t szt
Size type, shorthand for size_t.
Definition: Core.h:90
String filepath
Definition: Log.h:66
const SinkMap & sinks() const
Definition: Log.h:105
unordered_map< Id, log::Sink::Ptr > SinkMap
Definition: Log.h:79
virtual void operator()(const Level &level, const String &record)
Definition: Log.cpp:67
DepGraph< const log::Level > LevelGraph
Definition: Log.h:78
RecordStream operator<<(const log::Level &level)
Push a record with level to all sinks.
Definition: Log.h:120
String srcFilename(const String &path)
Get filename from source path provided by macro FILE
Definition: Log.h:71
SharedPtr< Sink > Ptr
Definition: Log.h:34
SharedPtr< FileSink > Ptr
Definition: Log.h:61
void addLevel(const log::Level &level)
Add a severity level to categorize records.
Definition: Log.cpp:92
Log * log
Definition: Log.h:87
RecordStream(RecordStream &&rhs)
Definition: Log.h:85
Holds a name string and its hashed value for fast comparison ops. See String Identifier.
Definition: Id.h:25
Builds a record.
Definition: Log.h:82
Global Honeycomb namespace.
DepNode< void *, NameId > Level
Severity level.
Definition: Log.h:17
void filter(const Id &sink, const vector< const log::Level * > &includes, bool includeDeps=true, const vector< const log::Level * > &excludes={}, bool excludeDeps=true)
Add a record filter to a sink.
Definition: Log.cpp:113
String format(const Level &level, const String &record)
Format record with date and level id.
Definition: Log.cpp:31