43 const tchar *
const fmt_t=fmt.c_str();
44 const tm *
const time=localtime(&base_time);
53 template<
class Except_>
60 virtual inline __stdcall ~
Logger(
void) {
71 return path_to_log_file;
81 const tchar *app_name;
85 template<
class Except_>
inline
87 : path_to_log_file(path),app_name(an),
91 assert(
sizeof(log_level_strs)/
sizeof(tchar *)==
static_cast<size_t>(log_info+1));
94 template<
class Except_>
inline void
96 if (at_level<=log_level) {
98 tofstream log_file(path_to_log_file.c_str(),
std::ios_base::out|
std::ios_base::app);
99 if (log_file.is_open()) {
100 OutputDateTime(log_file);
102 <<(getenv(
_T(
"LOGNAME")) ? getenv(
_T(
"LOGNAME")) :
_T(
"LOGNAME"))
104 <<(getenv(
_T(
"HOSTNAME")) ? getenv(
_T(
"HOSTNAME")) :
_T(
"HOSTNAME"))
106 <<(getenv(
_T(
"HOSTTYPE")) ? getenv(
_T(
"HOSTTYPE")) :
_T(
"HOSTTYPE"))
108 <<(getenv(
_T(
"OSTYPE")) ? getenv(
_T(
"OSTYPE")) :
_T(
"OSTYPE"))
111 <<
_T(
"[")<<getpid()<<
_T(
"] ")
116 ss<<
_T(
"Failed to open '")<<path_to_log_file<<
_T(
"' for writing log information.");
117 info::
function fun(__LINE__,
__PRETTY_FUNCTION__,
typeid(*
this),info::function::argument(
_T(
"Log level."),log_level_strs[at_level]));
119 info::function::argument(
_T(
"Log message."),msg),
120 info::function::argument(
_T(
"Logging at level."),log_level_strs[log_level])
124 }
catch (
const exception &) {
126 }
catch (
const std::exception &e) {
128 ss<<
_T(
"STL exception caught whilst attempting to log. Details: ")<<e.what();
129 info::
function fun(__LINE__,
__PRETTY_FUNCTION__,
typeid(*
this),info::function::argument(
_T(
"Log level."),log_level_strs[at_level]));
131 info::function::argument(
_T(
"Log message."),msg),
132 info::function::argument(
_T(
"Logging at level."), log_level_strs[log_level]),
133 info::function::argument(
_T(
"Logging to file."), path_to_log_file)
140 #define JMMCG_LOG(logger_,at_level_,msg_)
141 if ((at_level_)>(logger_)->Level()) {
144 (logger_)->Log((at_level_),(msg_));