Protocol++® (Protocolpp®)  v5.7.0
InterfacePP::jlogger Class Reference

#include "include/jlogger.h"

Public Types

enum  asciicolor {
  BLACK =30 , RED =31 , GREEN =32 , YELLOW =33 ,
  BLUE =34 , MAGENTA =35 , CYAN =36 , WHITE =37 ,
  BRIGHTBLACK =90 , BRIGHTRED =91 , BRIGHTGREEN =92 , BRIGHTYELLOW =93 ,
  BRIGHTBLUE =94 , BRIGHTMAGENTA =95 , BRIGHTCYAN =96 , BRIGHTWHITE =97
}
 
enum  severity_t {
  debug =1 , info , warning , error ,
  fatal , pass
}
 

Public Member Functions

 jlogger (const std::string &name, bool logstdout=false, severity_t loglvl=severity_t::info, jlogger::asciicolor debugclr=jlogger::asciicolor::MAGENTA, jlogger::asciicolor infoclr=jlogger::asciicolor::CYAN, jlogger::asciicolor warningclr=jlogger::asciicolor::BRIGHTYELLOW, jlogger::asciicolor errorclr=jlogger::asciicolor::RED, jlogger::asciicolor fatalclr=jlogger::asciicolor::RED, jlogger::asciicolor passclr=jlogger::asciicolor::GREEN)
 
template<typename jlogger::severity_t , typename... Args>
void print (Args...args)
 
 ~jlogger ()
 standard deconstructor
 
void set_loglvl (severity_t newlvl)
 
void set_color (std::string color, jlogger::asciicolor jcolor)
 
severity_t get_loglvl ()
 
jlogger::asciicolor get_color (std::string color)
 

Static Public Member Functions

static std::string toStr (jlogger::asciicolor jcolor)
 
static std::string toCode (jlogger::asciicolor jcolor)
 
static jlogger::asciicolor toEnum (std::string color)
 

Detailed Description

#ifdef DARK_THEME line.insert(0, "\033[1;34m "); #else line.insert(0, "\033[1;30m "); #endif } else if (line.find("<DEBUG>") != std::string::npos) { #ifdef DARK_THEME line.insert(0, "\033[1;35m "); #else line.insert(0, "\033[1;34m "); #endif } else if (line.find("<WARN>") != std::string::npos) { #ifdef LIGHT_THEME line.insert(0, "\033[0;34m "); #else line.insert(0, "\033[1;33m "); #endif } else if (line.find("<ERROR>") != std::string::npos) { #ifdef LIGHT_THEME line.insert(0, "\033[1;31m "); #else line.insert(0, "\033[1;31m "); #endif } else if (line.find("<FATAL>") != std::string::npos) { #ifdef DARK_THEME line.insert(0, "\033[1;35m "); #else line.insert(0, "\033[1;35m "); #endif } else if (line.find("<PASS>") != std::string::npos) { #ifdef DARK_THEME line.insert(0, "\033[1;32m "); #else line.insert(0, "\033[1;32m "); #endif } else { #ifdef DARK_THEME line.insert(0, "\033[1;34m "); #else line.insert(0, "\033[1;34m "); #endif

Member Enumeration Documentation

◆ asciicolor

Color enums

Parameters
BLACK- Standard black
RED- Standard red
GREEN- Standard green
YELLOW- Standard yellow
BLUE- Standard blue
MAGENTA- Standard magenta
CYAN- Standard cyan
WHITE- Standard white
BRIGHTBLACK- Bold black
BRIGHTRED- Bold red
BRIGHTGREEN- Bold green
BRIGHTYELLOW- Bold yellow
BRIGHTBLUE- Bold blue
BRIGHTMAGENTA- Bold magenta
BRIGHTCYAN- Bold cyan
BRIGHTWHITE- Bold white
Enumerator
BLACK 

Standard black.

RED 

Standard red.

GREEN 

Standard green.

YELLOW 

Standard yellow.

BLUE 

Standard blue.

MAGENTA 

Standard magenta.

CYAN 

Standard cyan.

WHITE 

Standard white.

BRIGHTBLACK 

Bold black.

BRIGHTRED 

Bold red.

BRIGHTGREEN 

Bold green.

BRIGHTYELLOW 

Bold yellow.

BRIGHTBLUE 

Bold blue.

BRIGHTMAGENTA 

Bold magenta.

BRIGHTCYAN 

Bold cyan.

BRIGHTWHITE 

Bold white.

◆ severity_t

severity type

Parameters
debug- debug level of logging
info- information level of logging
warning- warning level of logging
error- error level of logging
fatal- fatal level of logging
pass- PASS banner level of logging
Enumerator
debug 

information level of logging

info 

debug level of logging

warning 

warning level of logging

error 

error level of logging

fatal 

fatal level of logging

pass 

PASS banner.

Constructor & Destructor Documentation

◆ jlogger()

InterfacePP::jlogger::jlogger ( const std::string &  name,
bool  logstdout = false,
severity_t  loglvl = severity_t::info,
jlogger::asciicolor  debugclr = jlogger::asciicolor::MAGENTA,
jlogger::asciicolor  infoclr = jlogger::asciicolor::CYAN,
jlogger::asciicolor  warningclr = jlogger::asciicolor::BRIGHTYELLOW,
jlogger::asciicolor  errorclr = jlogger::asciicolor::RED,
jlogger::asciicolor  fatalclr = jlogger::asciicolor::RED,
jlogger::asciicolor  passclr = jlogger::asciicolor::GREEN 
)
explicit

logger class

Parameters
name- name of the output log file
logstdout- print logging to stdout as well as file
loglvl- From severity_t (default: severity_t::info)
debugclr- Color for the DEBUG messages (default: MAGENTA)
infoclr- Color for the INFO messages (default: BLACK)
warningclr- Color for the WARN messages (default: YELLOW)
errorclr- Color for the ERROR messages (default:RED)
fatalclr- Color for the FATAL messages (default:RED)
passclr- Color for the PASS messages (default:GREEN)

Member Function Documentation

◆ get_color()

jlogger::asciicolor InterfacePP::jlogger::get_color ( std::string  color)

Obtain current color for logging field

Parameters
color- Color to set values are DEBUGCLR, INFOCLR, WARNCLR, ERRCLR, FATALCLR, PASSCLR
Returns
Returns the jlogger::asciicolor Enum value of the color

◆ get_loglvl()

severity_t InterfacePP::jlogger::get_loglvl ( )

get the loggging level

Returns
Returns the logging level

◆ print()

template<jlogger::severity_t severity, typename... Args>
void InterfacePP::jlogger::print ( Args...  args)

print function for logger

Parameters
Args...args- variable number of arguments to print

◆ set_color()

void InterfacePP::jlogger::set_color ( std::string  color,
jlogger::asciicolor  jcolor 
)

Change colors for the logging output

Parameters
color- Color to set values are DEBUGCLR, INFOCLR, WARNCLR, ERRCLR, FATALCLR, PASSCLR
jcolor- Enum value of new color

◆ set_loglvl()

void InterfacePP::jlogger::set_loglvl ( severity_t  newlvl)

set the loggging level

Parameters
newlvl- new logging level

◆ toCode()

static std::string InterfacePP::jlogger::toCode ( jlogger::asciicolor  jcolor)
static

Convert jlogger::asciicolor Enum to a ASCII color code string

Parameters
jcolor- Enum to convert
Returns
ASCII color code string

◆ toEnum()

static jlogger::asciicolor InterfacePP::jlogger::toEnum ( std::string  color)
static

Convert string to jlogger::asciicolor Enum

Parameters
color- Color to convert
Returns
Returns the jlogger::asciicolor Enum value of the color

◆ toStr()

static std::string InterfacePP::jlogger::toStr ( jlogger::asciicolor  jcolor)
static

Convert jlogger::asciicolor Enum to a string representation

Parameters
jcolor- Enum to convert
Returns
Returns the string name of the color

The documentation for this class was generated from the following file: