fastcgi++  3.1alpha
A C++ FastCGI/Web API
log.hpp File Reference

Declares the Fastcgipp debugging/logging facilities. More...

#include "fastcgi++/config.hpp"
#include <ostream>
#include <mutex>
#include <cstdlib>
#include <string>
Include dependency graph for log.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Namespaces

 Fastcgipp
 Topmost namespace for the fastcgi++ library.
 
 Fastcgipp::Logging
 Contains the Fastcgipp debugging/logging mechanism.
 

Macros

#define INFO_LOG(data)
 This is for the user to log whatever they want. More...
 
#define FAIL_LOG(data)
 Log any "errors" that cannot be recovered from and then exit. More...
 
#define ERROR_LOG(data)
 Log any "errors" that can be recovered from. More...
 
#define WARNING_LOG(data)
 Log any externally caused "errors". More...
 
#define DEBUG_LOG(data)
 The intention here is for general debug/analysis logging. More...
 
#define DIAG_LOG(data)   {}
 

Enumerations

enum  Fastcgipp::Logging::Level {
  Fastcgipp::Logging::INFO = 0, Fastcgipp::Logging::FAIL = 1, Fastcgipp::Logging::ERROR = 2, Fastcgipp::Logging::WARNING = 3,
  Fastcgipp::Logging::DEBUG = 4, Fastcgipp::Logging::DIAG = 5
}
 Communicate the log level to the header generator. More...
 

Functions

void Fastcgipp::Logging::header (Level level)
 Send a log header to logstream. More...
 

Variables

std::wostream * Fastcgipp::Logging::logstream
 The actual stream we will be logging to. More...
 
std::mutex Fastcgipp::Logging::mutex
 Thread safe the logging mechanism. More...
 
std::wstring Fastcgipp::Logging::hostname
 Hostname to use in logging. More...
 
std::wstring Fastcgipp::Logging::program
 Application name to use in loggin. More...
 
bool Fastcgipp::Logging::suppress
 Set to true if you want to suppress non-error logs. More...
 

Detailed Description

Declares the Fastcgipp debugging/logging facilities.

Author
Eddie Carle <eddie.nosp@m.@isa.nosp@m.tec.c.nosp@m.a>
Date
May 4, 2017

Definition in file log.hpp.

Macro Definition Documentation

◆ DEBUG_LOG

#define DEBUG_LOG (   data)
Value:

The intention here is for general debug/analysis logging.

Definition at line 137 of file log.hpp.

◆ DIAG_LOG

#define DIAG_LOG (   data)    {}

Definition at line 158 of file log.hpp.

◆ ERROR_LOG

#define ERROR_LOG (   data)
Value:
{ \
std::lock_guard<std::mutex> lock(::Fastcgipp::Logging::mutex);\
*::Fastcgipp::Logging::logstream << data << std::endl;\
}

Log any "errors" that can be recovered from.

This should encompass all errors that should never happen, regardless of what the external conditions are. This also presumes that there is a mechanism to recover from said error.

Definition at line 107 of file log.hpp.

◆ FAIL_LOG

#define FAIL_LOG (   data)
Value:
{\
{ \
std::lock_guard<std::mutex> lock(::Fastcgipp::Logging::mutex);\
*::Fastcgipp::Logging::logstream << data << std::endl;\
std::exit(EXIT_FAILURE);\
}}

Log any "errors" that cannot be recovered from and then exit.

This should encompass all errors that should never happen, regardless of what the external conditions are. This also presumes that there is no possibility to recover from the error and we should simply terminate.

Definition at line 91 of file log.hpp.

◆ INFO_LOG

#define INFO_LOG (   data)
Value:

This is for the user to log whatever they want.

Definition at line 77 of file log.hpp.

◆ WARNING_LOG

#define WARNING_LOG (   data)
Value:

Log any externally caused "errors".

We allocate this "log level" to errors that are caused by external factors like bad data from a web server. Once can't say that these errors should never happen since they are external controlled.

Definition at line 124 of file log.hpp.

Fastcgipp::Logging::FAIL
@ FAIL
Definition: log.hpp:98
Fastcgipp::Logging::INFO
@ INFO
Definition: log.hpp:97
Fastcgipp::Logging::mutex
std::mutex mutex
Thread safe the logging mechanism.
Definition: log.cpp:102
Fastcgipp::Logging::ERROR
@ ERROR
Definition: log.hpp:99
Fastcgipp::Logging::WARNING
@ WARNING
Definition: log.hpp:100
Fastcgipp::Logging::suppress
bool suppress
Set to true if you want to suppress non-error logs.
Fastcgipp::Logging::DEBUG
@ DEBUG
Definition: log.hpp:101
Fastcgipp::Logging::logstream
std::wostream * logstream
The actual stream we will be logging to.
Fastcgipp::Logging::header
void header(Level level)
Send a log header to logstream.
Definition: log.cpp:107