Toolbox snapshot
The Reactive C++ Toolbox
|
Namespaces | |
namespace | detail |
Classes | |
class | AsyncLogger |
class | CyclTime |
struct | IsoDatePolicy |
struct | JDayPolicy |
class | Log |
class | Logger |
struct | MonoClock |
struct | PutTime |
class | Runner |
class | ScopedLogger |
class | ScopedLogLevel |
class | SigWait |
struct | ThreadConfig |
ThreadConfig holds the thread attributes. More... | |
struct | WallClock |
Typedefs | |
using | IsoDate = IntWrapper< IsoDatePolicy > |
ISO8601 date in yyymmdd format. | |
using | JDay = IntWrapper< JDayPolicy > |
Julian day. | |
using | LogStream = util::OStream< MaxLogLine > |
Logger callback function. | |
using | LogMsgPtr = StoragePtr< MaxLogLine > |
using | PidFile = std::unique_ptr< pidfh, detail::PidFileDeleter > |
using | Seconds = std::chrono::seconds |
using | Decis = std::chrono::duration< int64_t, std::deci > |
using | Millis = std::chrono::milliseconds |
using | Micros = std::chrono::microseconds |
using | Nanos = std::chrono::nanoseconds |
using | NanoTime = Nanos |
using | Duration = Nanos |
using | MonoTime = MonoClock::time_point |
using | WallTime = WallClock::time_point |
Enumerations | |
enum | : std::size_t { CacheLineBits = 6 , CacheLineSize = 1 << CacheLineBits , PageBits = 12 , PageSize = 1 << PageBits , MaxLogLine = 4096 } |
enum class | LogLevel : int { None , Crit , Error , Warn , Metric , Notice , Info , Debug } |
Definition at line 51 of file Logger.hpp.
using toolbox::sys::PidFile = typedef std::unique_ptr<pidfh, detail::PidFileDeleter> |
Definition at line 34 of file PidFile.hpp.
using toolbox::sys::Seconds = typedef std::chrono::seconds |
using toolbox::sys::Decis = typedef std::chrono::duration<int64_t, std::deci> |
using toolbox::sys::Millis = typedef std::chrono::milliseconds |
using toolbox::sys::Micros = typedef std::chrono::microseconds |
using toolbox::sys::Nanos = typedef std::chrono::nanoseconds |
Enumerator | |
---|---|
CacheLineBits | |
CacheLineSize | |
PageBits | |
PageSize | |
MaxLogLine | Maximum log line size. |
Definition at line 29 of file Limits.hpp.
|
strong |
Enumerator | |
---|---|
None | None. |
Crit | Critical. |
Error | Error. |
Warn | Warning. |
Metric | |
Notice | Notice. |
Info | Information. |
Debug | Debug. |
Definition at line 32 of file Logger.hpp.
|
noexcept |
Close all non-standard file handles.
Definition at line 27 of file Daemon.cpp.
TOOLBOX_API void toolbox::sys::daemon | ( | ) |
Daemonise process. Detach from controlling terminal and run in the background as a system daemon.
Definition at line 36 of file Daemon.cpp.
Date represented in UTC (Universal Time Coordinated, also known as "GMT") in YYYYMMDD format. This special-purpose field is paired with UTCTimeOnly to form a proper UTCTimestamp for bandwidth-sensitive messages.
Valid values:
|
constexprnoexcept |
Time/date combination represented in UTC (Universal Time Coordinated, also known as "GMT") in either YYYYMMDD-HH:MM:SS (whole seconds) or YYYYMMDD-HH:MM:SS.sss (milliseconds) format, colons, dash, and period required.
Valid values:
|
inlinenoexcept |
Definition at line 25 of file Error.hpp.
Referenced by toolbox::sys::SigWait::operator()(), toolbox::sys::SigWait::operator()(), and toolbox::sys::SigWait::SigWait().
|
constexprnoexcept |
Definition at line 38 of file Limits.hpp.
|
constexprnoexcept |
Definition at line 43 of file Limits.hpp.
|
noexcept |
|
noexcept |
Null logger. This logger does nothing and is effectively /dev/null.
Definition at line 140 of file Logger.cpp.
|
noexcept |
Standard logger. This logger writes to stdout if the log level is greater than LogWarn, and stdout otherwise.
Definition at line 145 of file Logger.cpp.
|
noexcept |
System logger. This logger calls syslog().
Definition at line 150 of file Logger.cpp.
|
noexcept |
Return log label for given log level.
Definition at line 155 of file Logger.cpp.
|
noexcept |
Return current log level.
Definition at line 160 of file Logger.cpp.
|
noexcept |
Set log level globally for all threads.
Definition at line 165 of file Logger.cpp.
|
noexcept |
Return current logger.
Definition at line 170 of file Logger.cpp.
|
noexcept |
Set logger globally for all threads.
Definition at line 175 of file Logger.cpp.
|
noexcept |
Unconditionally write log message to the logger. Specifically, this function does not check that level is allowed by the current log level; users are expected to call is_log_level() first, before formatting the log message.
Definition at line 180 of file Logger.cpp.
Referenced by toolbox::sys::Log::~Log().
Return true if level is less than or equal to current log level.
Definition at line 70 of file Logger.hpp.
|
inlinenoexcept |
Definition at line 84 of file Logger.hpp.
|
inline |
Definition at line 202 of file Logger.hpp.
TOOLBOX_API PidFile toolbox::sys::open_pid_file | ( | const char * | path, |
mode_t | mode | ||
) |
Create pidfile and obtain lock. An exception is thrown if the pidfile cannot be locked, because a daemon is already running. If the path argument is null, then /var/run/{progname}.pid is used as the pidfile location.
Definition at line 38 of file PidFile.cpp.
|
noexcept |
Close pidfile without removing it. This function should be used when forking daemon processes.
Definition at line 51 of file PidFile.cpp.
TOOLBOX_API void toolbox::sys::write_pid_file | ( | PidFile & | pf | ) |
Write process' PID into pidfile.
Definition at line 58 of file PidFile.cpp.
TOOLBOX_API void toolbox::sys::sig_block_all | ( | ) |
Block all signals.
Definition at line 82 of file Signal.cpp.
Referenced by toolbox::sys::Runner< RunnableT >::operator=().
|
noexcept |
Parse an isolcpus-style set of CPUs.
The CPU set is either a list: "<cpu>,...,<cpu>", or a range: "<cpu>-<cpu>", or a combination or both: "<cpu>,...,<cpu>-<cpu>", where "<cpu>" begins at 0 and the maximum value is "number of CPUs in system - 1". For example: "0,1,10-11,22-23".
s | An isolcpus-style set of CPUs. |
Definition at line 35 of file Thread.cpp.
TOOLBOX_API int toolbox::sys::parse_sched_policy | ( | std::string_view | s | ) |
Parse scheduler policy name, where
s | is one of: other, fifo, rr, batch or idle. |
Realtime scheduling policies are: fifo and rr.
s | The policy name. |
Definition at line 51 of file Thread.cpp.
TOOLBOX_API void toolbox::sys::set_thread_attrs | ( | const ThreadConfig & | config | ) |
Set attributes for current thread from config.
config | The configuration. |
Definition at line 70 of file Thread.cpp.
Referenced by toolbox::sys::Runner< RunnableT >::operator=().
|
noexcept |
Definition at line 25 of file Time.cpp.
Referenced by toolbox::sys::MonoClock::now(), and toolbox::sys::WallClock::now().
TOOLBOX_API std::ostream & toolbox::sys::operator<< | ( | ostream & | os, |
MonoTime | t | ||
) |
TOOLBOX_API std::ostream & toolbox::sys::operator<< | ( | ostream & | os, |
WallTime | t | ||
) |
|
constexprnoexcept |
Definition at line 234 of file Time.hpp.
Referenced by toolbox::sys::SigWait::operator()().
|
constexprnoexcept |
Time-only represented in UTC (Universal Time Coordinated, also known as "GMT") in either HH:MM:SS (whole seconds) or HH:MM:SS.sss (milliseconds) format, colons, and period required. This special-purpose field is paired with UTCDateOnly to form a proper UTCTimestamp for bandwidth-sensitive messages. Valid values: HH = 00-23, MM = 00-59, SS = 00-5960 (60 only if UTC leap second) (without milliseconds). HH = 00-23, MM = 00-59, SS = 00-5960 (60 only if UTC leap second), sss=000-999 (indicating milliseconds).