Remove timestamp from loglines

when syslog is used
This commit is contained in:
benrubson 2017-03-09 14:07:58 +01:00 committed by rfjakob
parent 42ef6ee0c7
commit b1a7e0ff5e
3 changed files with 17 additions and 15 deletions

View File

@ -6,17 +6,28 @@ el::base::DispatchAction rlogAction = el::base::DispatchAction::NormalLog;
Error::Error(const char *msg) : runtime_error(msg) {}
void initLogging(bool enable_debug) {
el::Loggers::addFlag(el::LoggingFlag::ColoredTerminalOutput);
void initLogging(bool enable_debug, bool is_daemon) {
el::Configurations defaultConf;
defaultConf.setToDefault();
defaultConf.set(el::Level::Verbose, el::ConfigurationType::Format,
std::string("%datetime %level [%fbase:%line] %msg"));
defaultConf.set(el::Level::Global, el::ConfigurationType::ToFile, "false");
std::string prefix = "%datetime ";
std::string suffix = " [%fbase:%line]";
if (is_daemon) {
prefix = "";
encfs::rlogAction = el::base::DispatchAction::SysLog;
}
else {
el::Loggers::addFlag(el::LoggingFlag::ColoredTerminalOutput);
}
if (!enable_debug) {
suffix = "";
defaultConf.set(el::Level::Debug, el::ConfigurationType::Enabled, "false");
}
else {
el::Loggers::setVerboseLevel(1);
}
defaultConf.setGlobally(el::ConfigurationType::Format, prefix + std::string("%level %msg") + suffix);
el::Loggers::reconfigureLogger("default", defaultConf);
}

View File

@ -23,7 +23,7 @@ class Error : public std::runtime_error {
} \
} while (0)
void initLogging(bool enable_debug = false);
void initLogging(bool enable_debug = false, bool is_daemon = false);
// This can be changed to change log action between normal and syslog logging.
// Not thread-safe, so any change must occur outside of threading context.

View File

@ -491,11 +491,6 @@ void *encfs_init(fuse_conn_info *conn) {
// set fuse connection options
conn->async_read = true;
if (ctx->args->isDaemon) {
// Switch to using syslog.
encfs::rlogAction = el::base::DispatchAction::SysLog;
}
// if an idle timeout is specified, then setup a thread to monitor the
// filesystem.
if (ctx->args->idleTimeout > 0) {
@ -539,11 +534,7 @@ int main(int argc, char *argv[]) {
return EXIT_FAILURE;
}
if (encfsArgs->isVerbose) {
el::Loggers::setVerboseLevel(1);
}
encfs::initLogging(encfsArgs->isVerbose);
encfs::initLogging(encfsArgs->isVerbose, encfsArgs->isDaemon);
VLOG(1) << "Root directory: " << encfsArgs->opts->rootDir;
VLOG(1) << "Fuse arguments: " << encfsArgs->toString();