fastcgi++
A C++ FastCGI/Web API
Namespaces | Macros | Enumerations | Functions | Variables
log.hpp File Reference

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

#include "fastcgi++/config.hpp"
#include <ostream>
#include <mutex>
#include <cstdlib>
#include <string>

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)   {}
 
#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)    {}

Definition at line 145 of file log.hpp.

◆ DIAG_LOG

#define DIAG_LOG (   data)    {}

◆ ERROR_LOG

#define ERROR_LOG (   data)
Value:
{ \
std::lock_guard<std::mutex> lock(::Fastcgipp::Logging::mutex);\
*::Fastcgipp::Logging::logstream << data << std::endl;\
}
void header(Level level)
Send a log header to logstream.
Definition: log.cpp:107
std::mutex mutex
Thread safe the logging mechanism.
Definition: log.cpp:102
std::wostream * logstream
The actual stream we will be logging to.

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.

Referenced by Fastcgipp::SocketGroup::connect(), Fastcgipp::SocketGroup::createSocket(), Fastcgipp::FcgiStreambuf< charT >::emptyBuffer(), Fastcgipp::Request< charT >::handler(), Fastcgipp::SocketGroup::listen(), Fastcgipp::Manager_base::localHandler(), Fastcgipp::operator<<(), Fastcgipp::SocketGroup::poll(), Fastcgipp::Request< charT >::setLocale(), and Fastcgipp::Socket::Socket().

◆ 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);\
}}
void header(Level level)
Send a log header to logstream.
Definition: log.cpp:107
std::mutex mutex
Thread safe the logging mechanism.
Definition: log.cpp:102
bool suppress
Set to true if you want to suppress non-error logs.
std::wostream * logstream
The actual stream we will be logging to.

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.

Referenced by Fastcgipp::SocketGroup::createSocket(), Fastcgipp::Manager_base::Manager_base(), Fastcgipp::SocketGroup::poll(), and Fastcgipp::SocketGroup::wake().

◆ INFO_LOG

#define INFO_LOG (   data)
Value:
{\
{ \
std::lock_guard<std::mutex> lock(::Fastcgipp::Logging::mutex);\
*::Fastcgipp::Logging::logstream << data << std::endl;\
}}
void header(Level level)
Send a log header to logstream.
Definition: log.cpp:107
std::mutex mutex
Thread safe the logging mechanism.
Definition: log.cpp:102
bool suppress
Set to true if you want to suppress non-error logs.
std::wostream * logstream
The actual stream we will be logging to.

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:
{\
{ \
std::lock_guard<std::mutex> lock(::Fastcgipp::Logging::mutex);\
*::Fastcgipp::Logging::logstream << data << std::endl;\
}}
void header(Level level)
Send a log header to logstream.
Definition: log.cpp:107
std::mutex mutex
Thread safe the logging mechanism.
Definition: log.cpp:102
bool suppress
Set to true if you want to suppress non-error logs.
std::wostream * logstream
The actual stream we will be logging to.

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.

Referenced by Fastcgipp::Http::Address::assign(), Fastcgipp::Logging::getHostname(), Fastcgipp::Logging::getProgram(), Fastcgipp::Request< charT >::handler(), Fastcgipp::SocketGroup::poll(), Fastcgipp::Manager_base::push(), Fastcgipp::Socket::read(), Fastcgipp::Manager_base::signalHandler(), Fastcgipp::Http::vecToString(), and Fastcgipp::Socket::write().