Adding possibility to set default logger format. Applying to gridftp and...

Adding possibility to set default logger format. Applying to gridftp and arched server through ARC_LOGGER_FORMAT environment variable.
parent 6d47987c
......@@ -307,6 +307,19 @@ int main(int argc, char **argv)
signal(SIGHUP,&sighup_handler);
// 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);
};
};
// Temporary stderr destination for error messages
Arc::LogStream logcerr(std::cerr);
Arc::Logger::getRootLogger().addDestination(logcerr);
......
......@@ -24,7 +24,8 @@
namespace Arc {
#define DefaultLogLevel (DEBUG)
static const Arc::LogLevel DefaultLogLevel = Arc::DEBUG;
static Arc::LogFormat DefaultLogFormat = Arc::LongFormat;
static std::string list_to_domain(const std::list<std::string>& subdomains) {
std::string domain;
......@@ -229,12 +230,16 @@ namespace Arc {
}
LogDestination::LogDestination()
: format(LongFormat) {}
: format(DefaultLogFormat) {}
void LogDestination::setFormat(const LogFormat& newformat) {
format = newformat;
}
void LogDestination::setDefaultFormat(const LogFormat& newformat) {
DefaultLogFormat = newformat;
}
void LogDestination::setPrefix(const std::string& pre) {
prefix = pre;
}
......
......@@ -215,6 +215,9 @@ namespace Arc {
/// Set format for this log destination.
void setFormat(const LogFormat& newformat);
/// Set format for any new log destination.
static void setDefaultFormat(const LogFormat& newformat);
/// Set a prefix for this log destination to be logged before messages.
/** The prefix is prepended to messages in all formats except EmptyFormat.
* \since Added in 4.0.0.
......
......@@ -123,6 +123,19 @@ 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);
};
};
// temporary stderr destination until configuration is read and used in daemon.daemon()
Arc::LogStream logcerr(std::cerr);
Arc::Logger::getRootLogger().addDestination(logcerr);
......@@ -184,6 +197,19 @@ int main(int argc,char** argv) {
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);
};
};
// 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