41 #include <sys/types.h> 51 char buffer[HOST_NAME_MAX+2];
52 gethostname(buffer,
sizeof(buffer));
53 std::wstring_convert<std::codecvt_utf8<wchar_t>,
wchar_t> converter;
56 return(converter.from_bytes(
58 buffer+std::strlen(buffer)));
60 catch(
const std::range_error& e)
62 WARNING_LOG(
"Error in hostname code conversion from utf8")
63 return std::wstring(L
"localhost");
70 std::wstring_convert<std::codecvt_utf8<wchar_t>,
wchar_t> converter;
71 std::wostringstream ss;
74 ss << converter.from_bytes(
75 program_invocation_name,
76 program_invocation_name
77 +std::strlen(program_invocation_name));
79 catch(
const std::range_error& e)
81 WARNING_LOG(
"Error in program name code conversion from utf8")
85 ss <<
'[' << getpid() <<
']';
89 std::array<std::wstring, 6>
levels 109 const std::time_t now = std::time(
nullptr);
111 << std::put_time(std::localtime(&now), L
"%b %d %H:%M:%S ")
Topmost namespace for the fastcgi++ library.
void header(Level level)
Send a log header to logstream.
std::mutex mutex
Thread safe the logging mechanism.
std::wstring getProgram()
bool suppress
Set to true if you want to suppress non-error logs.
std::wstring getHostname()
Level
Communicate the log level to the header generator.
std::wostream * logstream
The actual stream we will be logging to.
std::array< std::wstring, 6 > levels
std::wstring program
Application name to use in loggin.
std::wstring hostname
Hostname to use in logging.
Declares the Fastcgipp debugging/logging facilities.
#define WARNING_LOG(data)
Log any externally caused "errors".