Evo C++ Library v0.5.1
Classes | Macros | Typedefs | Enumerations | Functions | Variables
EvoTools

Evo command-line and misc helper tools. More...

Classes

class  Benchmark
 Micro benchmarking class. More...
 
class  CommandLineT< ConsoleT >
 Process command-line arguments. More...
 
class  Cortex< T >
 A Map with a collection of independent abstract context items. More...
 
struct  CortexModuleAsBase< T >
 Helper for getting a concrete module from a CortexModulePtr (or similar pointer). More...
 
struct  CortexModuleBase
 A simple base class for defining a module using a similar pattern to Cortex, but without the dynamic Map. More...
 
class  ExceptionLogger
 Logger exception, see Exception. More...
 
class  Logger< MSG_BUF_SIZE >
 High performance message logger. More...
 
class  LoggerBase
 Base class for Logger. More...
 
class  LoggerConsole
 Logger that writes to console. More...
 
class  LoggerInert
 Inert logger implementing the same interface as Logger. More...
 
struct  LoggerPtr< T >
 Wraps a logger pointer that can reference a logger to use or be disabled. More...
 
struct  LogLevelEnum
 LogLevel enum helper created with EVO_ENUM_REMAP(). More...
 
class  Signal
 Process signal handling. More...
 

Macros

#define EVO_CORTEX_DYNAMIC_CAST   1
 Set whether Cortex uses dynamic_cast. More...
 

Typedefs

typedef CommandLineT CommandLine
 Process command-line arguments. More...
 
typedef SharedPtr< CortexModuleBaseCortexModulePtr
 Smart/Shared pointer to a class inheriting CortexModuleBase. More...
 
typedef pid_t ProcessId
 Process ID type. More...
 

Enumerations

enum  LogLevel {
  LOG_LEVEL_DISABLED = 0, LOG_LEVEL_ALERT, LOG_LEVEL_ERROR, LOG_LEVEL_WARN,
  LOG_LEVEL_INFO, LOG_LEVEL_DEBUG, LOG_LEVEL_DEBUG_LOW
}
 Log severity level used with Logger. More...
 

Functions

bool daemonize (uint flags=0)
 Daemonize current process to run in background as a service (Linux/Unix). More...
 
ProcessId get_pid ()
 Get current process ID. More...
 

Variables

static const uint DAEMONIZE_NO_CD = 0x01
 Flag to skip changing current directory – see daemonize() More...
 
static const uint DAEMONIZE_NO_EXIT = 0x04
 Flag to return false on error instead of calling exit(1) – see daemonize() More...
 
static const uint DAEMONIZE_NO_REDIR = 0x02
 Flag to skip std in/out/err redirects – see daemonize() More...
 
static const uint DAEMONIZE_USE_STDERR = 0x08
 Flag to use stderr instead of syslog for writing errors – see daemonize() More...
 
static const LogLevel LOG_LEVEL_REMAP []
 Log level remapping for EVO_ENUM_REMAP(). More...
 

Detailed Description

Evo command-line and misc helper tools.

Macro Definition Documentation

◆ EVO_CORTEX_DYNAMIC_CAST

#define EVO_CORTEX_DYNAMIC_CAST   1

Set whether Cortex uses dynamic_cast.

  • This defaults to 1, to use static_cast instead define EVO_CORTEX_DYNAMIC_CAST 0 (before including cortex.h)
  • Caution: static_cast does not do runtime checks and may be considered more dangerous, though dynamic_cast doesn't catch all invalid casts either

Typedef Documentation

◆ CommandLine

Process command-line arguments.

◆ CortexModulePtr

Smart/Shared pointer to a class inheriting CortexModuleBase.

◆ ProcessId

typedef pid_t ProcessId

Process ID type.

Enumeration Type Documentation

◆ LogLevel

enum LogLevel

Log severity level used with Logger.

Enumerator
LOG_LEVEL_DISABLED 

Logging disabled.

LOG_LEVEL_ALERT 

Alert message for critical alert that needs immediate attention, program may be unstable (ALRT)

LOG_LEVEL_ERROR 

Error message showing something isn't working as expected, program may be able to work around it (ERRR)

LOG_LEVEL_WARN 

Warning message that can indicate a potential issue, this may lead to an error or alert (WARN)

LOG_LEVEL_INFO 

Informational message for showing notices and context (INFO)

LOG_LEVEL_DEBUG 

High-level debug message, used for showing debug info for higher-level behavior (DBUG)

LOG_LEVEL_DEBUG_LOW 

Low-level debug message, used for showing debug info for lower-level internal or library details (DBGL)

Function Documentation

◆ daemonize()

bool evo::daemonize ( uint  flags = 0)
inline

Daemonize current process to run in background as a service (Linux/Unix).

  • #include <evo/process.h>
  • This writes errors to syslog by default, or writes errors to stderr if flags & DAEMONIZE_USE_STDERR
    • This is useful when stderr has been redirected to a log file
  • By default, this never returns on error and instead does exit(1) on error, unless flags & DAEMONIZE_NO_EXIT
  • Not supported in Windows
Parameters
flagsFlags combined with bitwise OR:
  • DAEMONIZE_NO_CD to skip changing current directory to /
  • DAEMONIZE_NO_REDIR to skip redirecting std in/out/err to /dev/null
  • DAEMONIZE_NO_EXIT to skip exit() on error and return false instead
  • DAEMONIZE_USE_STDERR to use stderr instead of syslog for error messages, and not redirect stderr if flags & DAEMONIZE_NO_REDIR
Returns
Whether successful, false on error if flags & DAEMONIZE_NO_EXIT, otherwise on error this calls exit(1) and never returns

◆ get_pid()

ProcessId evo::get_pid ( )
inline

Get current process ID.

Returns
Current process ID

Variable Documentation

◆ DAEMONIZE_NO_CD

const uint DAEMONIZE_NO_CD = 0x01
static

Flag to skip changing current directory – see daemonize()

◆ DAEMONIZE_NO_EXIT

const uint DAEMONIZE_NO_EXIT = 0x04
static

Flag to return false on error instead of calling exit(1) – see daemonize()

◆ DAEMONIZE_NO_REDIR

const uint DAEMONIZE_NO_REDIR = 0x02
static

Flag to skip std in/out/err redirects – see daemonize()

◆ DAEMONIZE_USE_STDERR

const uint DAEMONIZE_USE_STDERR = 0x08
static

Flag to use stderr instead of syslog for writing errors – see daemonize()

◆ LOG_LEVEL_REMAP

const LogLevel LOG_LEVEL_REMAP[]
static
Initial value:
= {
}
High-level debug message, used for showing debug info for higher-level behavior (DBUG) ...
Definition: logger.h:136
Informational message for showing notices and context (INFO)
Definition: logger.h:135
Low-level debug message, used for showing debug info for lower-level internal or library details (DBG...
Definition: logger.h:137
Alert message for critical alert that needs immediate attention, program may be unstable (ALRT) ...
Definition: logger.h:132
Warning message that can indicate a potential issue, this may lead to an error or alert (WARN) ...
Definition: logger.h:134
Error message showing something isn&#39;t working as expected, program may be able to work around it (ERR...
Definition: logger.h:133

Log level remapping for EVO_ENUM_REMAP().