Commit ea27d92d authored by Aleksandr Konstantinov's avatar Aleksandr Konstantinov
Browse files

Modifying log time format control to use time formats instead of log formats.

parent ac10139c
......@@ -15,6 +15,7 @@
#include <arc/ArcConfig.h>
#include <arc/IniConfig.h>
#include <arc/ArcLocation.h>
#include <arc/DateTime.h>
#include <arc/Logger.h>
#include <arc/XMLNode.h>
#include <arc/StringConv.h>
......@@ -308,16 +309,24 @@ int main(int argc, char **argv)
// Set up Glib exception handler
Glib::add_exception_handler(sigc::ptr_fun(&glib_exception_handler));
// Debug code for setting different logging formats
char const * log_format = ::getenv("ARC_LOGGER_FORMAT");
if(log_format) {
if(strcmp(log_format,"SHORT") == 0) {
Arc::LogDestination::setDefaultFormat(Arc::ShortFormat);
} else if(strcmp(log_format,"MEDIUM") == 0) {
Arc::LogDestination::setDefaultFormat(Arc::MediumFormat);
} else if(strcmp(log_format,"LONG") == 0) {
Arc::LogDestination::setDefaultFormat(Arc::LongFormat);
} else if(strcmp(log_format,"DEBUG") == 0) {
Arc::LogDestination::setDefaultFormat(Arc::DebugFormat);
char const * log_time_format = ::getenv("ARC_LOGGER_TIME_FORMAT");
if(log_time_format) {
if(strcmp(log_time_format,"USER") == 0) {
Arc::Time::SetFormat(Arc::UserTime);
} else if(strcmp(log_time_format,"USEREXT") == 0) {
Arc::Time::SetFormat(Arc::UserExtTime);
} else if(strcmp(log_time_format,"MDS") == 0) {
Arc::Time::SetFormat(Arc::MDSTime);
} else if(strcmp(log_time_format,"ASC") == 0) {
Arc::Time::SetFormat(Arc::ASCTime);
} else if(strcmp(log_time_format,"ISO") == 0) {
Arc::Time::SetFormat(Arc::ISOTime);
} else if(strcmp(log_time_format,"UTC") == 0) {
Arc::Time::SetFormat(Arc::UTCTime);
} else if(strcmp(log_time_format,"RFC1123") == 0) {
Arc::Time::SetFormat(Arc::RFC1123Time);
} else if(strcmp(log_time_format,"EPOCH") == 0) {
Arc::Time::SetFormat(Arc::EpochTime);
};
};
// Temporary stderr destination for error messages
......
......@@ -122,20 +122,26 @@ void sig_term(int signum) {
int main_internal(int argc,char** argv);
int main(int argc,char** argv) {
char const * log_format = ::getenv("ARC_LOGGER_FORMAT");
if(log_format) {
if(strcmp(log_format,"SHORT") == 0) {
Arc::LogDestination::setDefaultFormat(Arc::ShortFormat);
} else if(strcmp(log_format,"MEDIUM") == 0) {
Arc::LogDestination::setDefaultFormat(Arc::MediumFormat);
} else if(strcmp(log_format,"LONG") == 0) {
Arc::LogDestination::setDefaultFormat(Arc::LongFormat);
} else if(strcmp(log_format,"DEBUG") == 0) {
Arc::LogDestination::setDefaultFormat(Arc::DebugFormat);
char const * log_time_format = ::getenv("ARC_LOGGER_TIME_FORMAT");
if(log_time_format) {
if(strcmp(log_time_format,"USER") == 0) {
Arc::Time::SetFormat(Arc::UserTime);
} else if(strcmp(log_time_format,"USEREXT") == 0) {
Arc::Time::SetFormat(Arc::UserExtTime);
} else if(strcmp(log_time_format,"MDS") == 0) {
Arc::Time::SetFormat(Arc::MDSTime);
} else if(strcmp(log_time_format,"ASC") == 0) {
Arc::Time::SetFormat(Arc::ASCTime);
} else if(strcmp(log_time_format,"ISO") == 0) {
Arc::Time::SetFormat(Arc::ISOTime);
} else if(strcmp(log_time_format,"UTC") == 0) {
Arc::Time::SetFormat(Arc::UTCTime);
} else if(strcmp(log_time_format,"RFC1123") == 0) {
Arc::Time::SetFormat(Arc::RFC1123Time);
} else if(strcmp(log_time_format,"EPOCH") == 0) {
Arc::Time::SetFormat(Arc::EpochTime);
};
};
// temporary stderr destination until configuration is read and used in daemon.daemon()
Arc::LogStream logcerr(std::cerr);
Arc::Logger::getRootLogger().addDestination(logcerr);
......@@ -196,20 +202,26 @@ int main(int argc,char** argv) {
#endif
setpgid(0,0);
#endif
char const * log_format = ::getenv("ARC_LOGGER_FORMAT");
if(log_format) {
if(strcmp(log_format,"SHORT") == 0) {
Arc::LogDestination::setDefaultFormat(Arc::ShortFormat);
} else if(strcmp(log_format,"MEDIUM") == 0) {
Arc::LogDestination::setDefaultFormat(Arc::MediumFormat);
} else if(strcmp(log_format,"LONG") == 0) {
Arc::LogDestination::setDefaultFormat(Arc::LongFormat);
} else if(strcmp(log_format,"DEBUG") == 0) {
Arc::LogDestination::setDefaultFormat(Arc::DebugFormat);
char const * log_time_format = ::getenv("ARC_LOGGER_TIME_FORMAT");
if(log_time_format) {
if(strcmp(log_time_format,"USER") == 0) {
Arc::Time::SetFormat(Arc::UserTime);
} else if(strcmp(log_time_format,"USEREXT") == 0) {
Arc::Time::SetFormat(Arc::UserExtTime);
} else if(strcmp(log_time_format,"MDS") == 0) {
Arc::Time::SetFormat(Arc::MDSTime);
} else if(strcmp(log_time_format,"ASC") == 0) {
Arc::Time::SetFormat(Arc::ASCTime);
} else if(strcmp(log_time_format,"ISO") == 0) {
Arc::Time::SetFormat(Arc::ISOTime);
} else if(strcmp(log_time_format,"UTC") == 0) {
Arc::Time::SetFormat(Arc::UTCTime);
} else if(strcmp(log_time_format,"RFC1123") == 0) {
Arc::Time::SetFormat(Arc::RFC1123Time);
} else if(strcmp(log_time_format,"EPOCH") == 0) {
Arc::Time::SetFormat(Arc::EpochTime);
};
};
// temporary stderr destination until configuration is read and used in daemon.daemon()
Arc::LogStream logcerr(std::cerr);
Arc::Logger::getRootLogger().addDestination(logcerr);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment