logging: enable debug log only in verbose mode

This commit is contained in:
Valient Gough 2016-05-23 20:31:52 -07:00
parent ad43aa10b2
commit 105a8acd60
No known key found for this signature in database
GPG Key ID: B515DCEB95967051
3 changed files with 16 additions and 10 deletions

View File

@ -6,4 +6,17 @@ 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);
el::Configurations defaultConf;
defaultConf.setToDefault();
defaultConf.set(el::Level::Verbose, el::ConfigurationType::Format,
std::string("%datetime %level [%fbase:%line] %msg"));
if (!enable_debug) {
defaultConf.set(el::Level::Debug, el::ConfigurationType::Enabled, "false");
}
el::Loggers::reconfigureLogger("default", defaultConf);
}
} // namespace encfs

View File

@ -23,14 +23,7 @@ class Error : public std::runtime_error {
} \
} while (0)
inline void initLogging() {
el::Configurations defaultConf;
defaultConf.setToDefault();
defaultConf.set(el::Level::Verbose, el::ConfigurationType::Format,
std::string("%datetime %level [%fbase:%line] %msg"));
el::Loggers::reconfigureLogger("default", defaultConf);
el::Loggers::addFlag(el::LoggingFlag::ColoredTerminalOutput);
}
void initLogging(bool enable_debug = 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

@ -524,8 +524,6 @@ void *encfs_init(fuse_conn_info *conn) {
void encfs_destroy(void *_ctx) {}
int main(int argc, char *argv[]) {
encfs::initLogging();
#if defined(ENABLE_NLS) && defined(LOCALEDIR)
setlocale(LC_ALL, "");
bindtextdomain(PACKAGE, LOCALEDIR);
@ -547,6 +545,8 @@ int main(int argc, char *argv[]) {
el::Loggers::setVerboseLevel(1);
}
encfs::initLogging(encfsArgs->isVerbose);
VLOG(1) << "Root directory: " << encfsArgs->opts->rootDir;
VLOG(1) << "Fuse arguments: " << encfsArgs->toString();