diff --git a/encfs/Error.cpp b/encfs/Error.cpp index 4f277e3..c4f6d79 100644 --- a/encfs/Error.cpp +++ b/encfs/Error.cpp @@ -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 diff --git a/encfs/Error.h b/encfs/Error.h index 56415ca..bcedd43 100644 --- a/encfs/Error.h +++ b/encfs/Error.h @@ -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. diff --git a/encfs/main.cpp b/encfs/main.cpp index c8936e7..d3cf573 100644 --- a/encfs/main.cpp +++ b/encfs/main.cpp @@ -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();