From 9d872ea00c3cc4d2d1acb6df750af7379898de98 Mon Sep 17 00:00:00 2001 From: Sebastian Messmer Date: Wed, 16 May 2018 23:03:03 -0700 Subject: [PATCH] - Fix clash of our ERROR log level with the ERROR macro defined in windows - Fix definition of log levels so msvc accepts them --- .../ondisk/OnDiskBlockStore2.cpp | 2 +- src/cpp-utils/assert/assert.h | 4 +- src/cpp-utils/assert/backtrace_nonwindows.cpp | 4 +- src/cpp-utils/assert/backtrace_windows.cpp | 2 +- src/cpp-utils/crypto/RandomPadding.cpp | 2 +- src/cpp-utils/logging/logging.h | 13 +++-- src/cpp-utils/process/daemonize.cpp | 4 +- src/cpp-utils/tempfile/TempDir.cpp | 2 +- src/cpp-utils/tempfile/TempFile.cpp | 2 +- src/cpp-utils/thread/ThreadSystem.cpp | 4 +- src/cryfs-cli/Cli.cpp | 4 +- src/cryfs/config/CryConfigFile.cpp | 4 +- .../crypto/inner/ConcreteInnerEncryptor.h | 4 +- src/cryfs/config/crypto/inner/InnerConfig.cpp | 4 +- src/cryfs/config/crypto/outer/OuterConfig.cpp | 4 +- src/cryfs/filesystem/CryDevice.cpp | 6 +-- src/fspp/fuse/Fuse.cpp | 52 +++++++++---------- test/cpp-utils/logging/LoggingLevelTest.cpp | 8 +-- test/cpp-utils/logging/LoggingTest.cpp | 2 +- 19 files changed, 66 insertions(+), 61 deletions(-) diff --git a/src/blockstore/implementations/ondisk/OnDiskBlockStore2.cpp b/src/blockstore/implementations/ondisk/OnDiskBlockStore2.cpp index 500330a7..c1c71f1a 100644 --- a/src/blockstore/implementations/ondisk/OnDiskBlockStore2.cpp +++ b/src/blockstore/implementations/ondisk/OnDiskBlockStore2.cpp @@ -62,7 +62,7 @@ bool OnDiskBlockStore2::remove(const BlockId &blockId) { } bool retval = boost::filesystem::remove(filepath); if (!retval) { - cpputils::logging::LOG(cpputils::logging::ERROR, "Couldn't find block {} to remove", blockId.ToString()); + cpputils::logging::LOG(cpputils::logging::ERR, "Couldn't find block {} to remove", blockId.ToString()); return false; } if (boost::filesystem::is_empty(filepath.parent_path())) { diff --git a/src/cpp-utils/assert/assert.h b/src/cpp-utils/assert/assert.h index 644b6ae1..68222e6b 100644 --- a/src/cpp-utils/assert/assert.h +++ b/src/cpp-utils/assert/assert.h @@ -23,13 +23,13 @@ namespace cpputils { inline void assert_fail_release [[noreturn]] (const char *expr, const std::string &message, const char *file, int line) { auto msg = format(expr, message, file, line); using namespace logging; - LOG(ERROR, msg); + LOG(ERR, msg); throw AssertFailed(msg); } inline void assert_fail_debug [[noreturn]] (const char *expr, const std::string &message, const char *file, int line) { using namespace logging; - LOG(ERROR, format(expr, message, file, line)); + LOG(ERR, format(expr, message, file, line)); abort(); } } diff --git a/src/cpp-utils/assert/backtrace_nonwindows.cpp b/src/cpp-utils/assert/backtrace_nonwindows.cpp index d38dd18f..f6576531 100644 --- a/src/cpp-utils/assert/backtrace_nonwindows.cpp +++ b/src/cpp-utils/assert/backtrace_nonwindows.cpp @@ -62,7 +62,7 @@ namespace { namespace { void sigsegv_handler(int) { - LOG(ERROR, "SIGSEGV\n{}", backtrace()); + LOG(ERR, "SIGSEGV\n{}", backtrace()); exit(1); } } @@ -70,7 +70,7 @@ namespace { void showBacktraceOnSigSegv() { auto result = signal(SIGSEGV, sigsegv_handler); if (SIG_ERR == result) { - LOG(ERROR, "Failed to set sigsegv signal handler. Errno: {}", errno); + LOG(ERR, "Failed to set sigsegv signal handler. Errno: {}", errno); } } diff --git a/src/cpp-utils/assert/backtrace_windows.cpp b/src/cpp-utils/assert/backtrace_windows.cpp index e322a70f..bab0570e 100644 --- a/src/cpp-utils/assert/backtrace_windows.cpp +++ b/src/cpp-utils/assert/backtrace_windows.cpp @@ -101,7 +101,7 @@ namespace cpputils { LONG WINAPI TopLevelExceptionHandler(PEXCEPTION_POINTERS pExceptionInfo) { std::string backtrace = backtrace_to_string(pExceptionInfo->ContextRecord); - LOG(ERROR, "Top level exception. Backtrace:\n{}", backtrace); + LOG(ERR, "Top level exception. Backtrace:\n{}", backtrace); return EXCEPTION_CONTINUE_SEARCH; } diff --git a/src/cpp-utils/crypto/RandomPadding.cpp b/src/cpp-utils/crypto/RandomPadding.cpp index 4dd2f5ba..041fa7dc 100644 --- a/src/cpp-utils/crypto/RandomPadding.cpp +++ b/src/cpp-utils/crypto/RandomPadding.cpp @@ -24,7 +24,7 @@ namespace cpputils { optional RandomPadding::remove(const Data &data) { uint32_t size = deserialize(data.data()); if(sizeof(size) + size >= data.size()) { - LOG(ERROR, "Config file is invalid: Invalid padding."); + LOG(ERR, "Config file is invalid: Invalid padding."); return boost::none; }; Data result(size); diff --git a/src/cpp-utils/logging/logging.h b/src/cpp-utils/logging/logging.h index f98aa79f..45ac3927 100644 --- a/src/cpp-utils/logging/logging.h +++ b/src/cpp-utils/logging/logging.h @@ -9,10 +9,15 @@ namespace cpputils { namespace logging { - constexpr struct ERROR_TYPE {} ERROR {}; - constexpr struct WARN_TYPE {} WARN {}; - constexpr struct INFO_TYPE {} INFO {}; - constexpr struct DEBUG_TYPE {} DEBUG {}; + struct ERROR_TYPE {}; + struct WARN_TYPE {}; + struct INFO_TYPE {}; + struct DEBUG_TYPE {}; + + constexpr ERROR_TYPE ERR; + constexpr WARN_TYPE WARN; + constexpr INFO_TYPE INFO; + constexpr DEBUG_TYPE DEBUG; inline void setLogger(std::shared_ptr newLogger) { logger().setLogger(newLogger); diff --git a/src/cpp-utils/process/daemonize.cpp b/src/cpp-utils/process/daemonize.cpp index fbc25ec6..b64d52da 100644 --- a/src/cpp-utils/process/daemonize.cpp +++ b/src/cpp-utils/process/daemonize.cpp @@ -34,13 +34,13 @@ namespace cpputils { // Create a new SID for the child process pid_t sid = setsid(); if (sid < 0) { - LOG(ERROR, "Failed to get SID for daemon process"); + LOG(ERR, "Failed to get SID for daemon process"); exit(EXIT_FAILURE); } // Change the current working directory to a directory that's always existin if ((chdir("/")) < 0) { - LOG(ERROR, "Failed to change working directory for daemon process"); + LOG(ERR, "Failed to change working directory for daemon process"); exit(EXIT_FAILURE); } diff --git a/src/cpp-utils/tempfile/TempDir.cpp b/src/cpp-utils/tempfile/TempDir.cpp index 9de918cb..1bcc5620 100644 --- a/src/cpp-utils/tempfile/TempDir.cpp +++ b/src/cpp-utils/tempfile/TempDir.cpp @@ -21,7 +21,7 @@ void TempDir::remove() { bf::remove_all(_path); } } catch (const boost::filesystem::filesystem_error &e) { - LOG(ERROR, "Could not delete tempfile."); + LOG(ERR, "Could not delete tempfile."); } } diff --git a/src/cpp-utils/tempfile/TempFile.cpp b/src/cpp-utils/tempfile/TempFile.cpp index 61710538..dba0acef 100644 --- a/src/cpp-utils/tempfile/TempFile.cpp +++ b/src/cpp-utils/tempfile/TempFile.cpp @@ -28,7 +28,7 @@ TempFile::~TempFile() { bf::remove(_path); } } catch (const boost::filesystem::filesystem_error &e) { - LOG(ERROR, "Could not delete tempfile."); + LOG(ERR, "Could not delete tempfile."); } } diff --git a/src/cpp-utils/thread/ThreadSystem.cpp b/src/cpp-utils/thread/ThreadSystem.cpp index 853da93e..83827576 100644 --- a/src/cpp-utils/thread/ThreadSystem.cpp +++ b/src/cpp-utils/thread/ThreadSystem.cpp @@ -77,9 +77,9 @@ namespace cpputils { } catch (const boost::thread_interrupted &e) { //Do nothing, exit thread. } catch (const std::exception &e) { - LOG(ERROR, "LoopThread crashed: {}", e.what()); + LOG(ERR, "LoopThread crashed: {}", e.what()); } catch (...) { - LOG(ERROR, "LoopThread crashed"); + LOG(ERR, "LoopThread crashed"); } //TODO We should remove the thread from _runningThreads here, not in stop(). } diff --git a/src/cryfs-cli/Cli.cpp b/src/cryfs-cli/Cli.cpp index 8d2f1cab..70bfe67e 100644 --- a/src/cryfs-cli/Cli.cpp +++ b/src/cryfs-cli/Cli.cpp @@ -259,9 +259,9 @@ namespace cryfs { } catch (const CryfsException &e) { throw; // CryfsException is only thrown if setup goes wrong. Throw it through so that we get the correct process exit code. } catch (const std::exception &e) { - LOG(ERROR, "Crashed: {}", e.what()); + LOG(ERR, "Crashed: {}", e.what()); } catch (...) { - LOG(ERROR, "Crashed"); + LOG(ERR, "Crashed"); } } diff --git a/src/cryfs/config/CryConfigFile.cpp b/src/cryfs/config/CryConfigFile.cpp index b34fcc43..83d4030e 100644 --- a/src/cryfs/config/CryConfigFile.cpp +++ b/src/cryfs/config/CryConfigFile.cpp @@ -28,7 +28,7 @@ CryConfigFile::~CryConfigFile() { optional CryConfigFile::load(bf::path path, const string &password) { auto encryptedConfigData = Data::LoadFromFile(path); if (encryptedConfigData == none) { - LOG(ERROR, "Config file not found"); + LOG(ERR, "Config file not found"); return none; } auto encryptor = CryConfigEncryptorFactory::loadKey(*encryptedConfigData, password); @@ -41,7 +41,7 @@ optional CryConfigFile::load(bf::path path, const string &passwor } CryConfig config = CryConfig::load(decrypted->data); if (config.Cipher() != decrypted->cipherName) { - LOG(ERROR, "Inner cipher algorithm used to encrypt config file doesn't match config value"); + LOG(ERR, "Inner cipher algorithm used to encrypt config file doesn't match config value"); return none; } auto configFile = CryConfigFile(std::move(path), std::move(config), std::move(*encryptor)); diff --git a/src/cryfs/config/crypto/inner/ConcreteInnerEncryptor.h b/src/cryfs/config/crypto/inner/ConcreteInnerEncryptor.h index 8f8c406f..f797f257 100644 --- a/src/cryfs/config/crypto/inner/ConcreteInnerEncryptor.h +++ b/src/cryfs/config/crypto/inner/ConcreteInnerEncryptor.h @@ -33,12 +33,12 @@ namespace cryfs { template boost::optional ConcreteInnerEncryptor::decrypt(const InnerConfig &innerConfig) const { if (innerConfig.cipherName != Cipher::NAME) { - cpputils::logging::LOG(cpputils::logging::ERROR, "Initialized ConcreteInnerEncryptor with wrong cipher"); + cpputils::logging::LOG(cpputils::logging::ERR, "Initialized ConcreteInnerEncryptor with wrong cipher"); return boost::none; } auto decrypted = Cipher::decrypt(static_cast(innerConfig.encryptedConfig.data()), innerConfig.encryptedConfig.size(), _key); if (decrypted == boost::none) { - cpputils::logging::LOG(cpputils::logging::ERROR, "Failed decrypting configuration file"); + cpputils::logging::LOG(cpputils::logging::ERR, "Failed decrypting configuration file"); return boost::none; } auto configData = cpputils::RandomPadding::remove(*decrypted); diff --git a/src/cryfs/config/crypto/inner/InnerConfig.cpp b/src/cryfs/config/crypto/inner/InnerConfig.cpp index e7226bb9..bdd62cc0 100644 --- a/src/cryfs/config/crypto/inner/InnerConfig.cpp +++ b/src/cryfs/config/crypto/inner/InnerConfig.cpp @@ -23,7 +23,7 @@ namespace cryfs { serializer.writeTailData(encryptedConfig); return serializer.finished(); } catch (const exception &e) { - LOG(ERROR, "Error serializing inner configuration: {}", e.what()); + LOG(ERR, "Error serializing inner configuration: {}", e.what()); throw; // This is a programming logic error, pass through exception. } } @@ -37,7 +37,7 @@ namespace cryfs { deserializer.finished(); return InnerConfig {cipherName, std::move(result)}; } catch (const exception &e) { - LOG(ERROR, "Error deserializing inner configuration: {}", e.what()); + LOG(ERR, "Error deserializing inner configuration: {}", e.what()); return none; // This can be caused by invalid input data and does not have to be a programming error. Don't throw exception. } } diff --git a/src/cryfs/config/crypto/outer/OuterConfig.cpp b/src/cryfs/config/crypto/outer/OuterConfig.cpp index 2260ffae..8041020b 100644 --- a/src/cryfs/config/crypto/outer/OuterConfig.cpp +++ b/src/cryfs/config/crypto/outer/OuterConfig.cpp @@ -38,7 +38,7 @@ namespace cryfs { serializer.writeTailData(encryptedInnerConfig); return serializer.finished(); } catch (const exception &e) { - LOG(ERROR, "Error serializing CryConfigEncryptor: {}", e.what()); + LOG(ERR, "Error serializing CryConfigEncryptor: {}", e.what()); throw; // This is a programming logic error. Pass through exception. } } @@ -60,7 +60,7 @@ namespace cryfs { return _deserializeNewFormat(&deserializer); #endif } catch (const exception &e) { - LOG(ERROR, "Error deserializing outer configuration: {}", e.what()); + LOG(ERR, "Error deserializing outer configuration: {}", e.what()); return none; // This can be caused by invalid input data and does not have to be a programming error. Don't throw exception. } } diff --git a/src/cryfs/filesystem/CryDevice.cpp b/src/cryfs/filesystem/CryDevice.cpp index 03ba7318..2352b417 100644 --- a/src/cryfs/filesystem/CryDevice.cpp +++ b/src/cryfs/filesystem/CryDevice.cpp @@ -201,7 +201,7 @@ CryDevice::BlobWithParent CryDevice::LoadBlobWithParent(const bf::path &path) { optional> parentBlob = none; optional> currentBlobOpt = _fsBlobStore->load(_rootBlobId); if (currentBlobOpt == none) { - LOG(ERROR, "Could not load root blob. Is the base directory accessible?"); + LOG(ERR, "Could not load root blob. Is the base directory accessible?"); throw FuseErrnoException(EIO); } unique_ref currentBlob = std::move(*currentBlobOpt); @@ -267,7 +267,7 @@ unique_ref CryDevice::CreateSymlinkBlob(const bf::path &target, unique_ref CryDevice::LoadBlob(const blockstore::BlockId &blockId) { auto blob = _fsBlobStore->load(blockId); if (blob == none) { - LOG(ERROR, "Could not load blob {}. Is the base directory accessible?", blockId.ToString()); + LOG(ERR, "Could not load blob {}. Is the base directory accessible?", blockId.ToString()); throw FuseErrnoException(EIO); } return std::move(*blob); @@ -276,7 +276,7 @@ unique_ref CryDevice::LoadBlob(const blockstore::BlockId &blockId) { void CryDevice::RemoveBlob(const blockstore::BlockId &blockId) { auto blob = _fsBlobStore->load(blockId); if (blob == none) { - LOG(ERROR, "Could not load blob {}. Is the base directory accessible?", blockId.ToString()); + LOG(ERR, "Could not load blob {}. Is the base directory accessible?", blockId.ToString()); throw FuseErrnoException(EIO); } _fsBlobStore->remove(std::move(*blob)); diff --git a/src/fspp/fuse/Fuse.cpp b/src/fspp/fuse/Fuse.cpp index 67dbf582..397e23e9 100644 --- a/src/fspp/fuse/Fuse.cpp +++ b/src/fspp/fuse/Fuse.cpp @@ -222,11 +222,11 @@ Fuse::Fuse(Filesystem *fs, std::string fstype, boost::optional fsna } void Fuse::_logException(const std::exception &e) { - LOG(ERROR, "Exception thrown: {}", e.what()); + LOG(ERR, "Exception thrown: {}", e.what()); } void Fuse::_logUnknownException() { - LOG(ERROR, "Unknown exception thrown"); + LOG(ERR, "Unknown exception thrown"); } void Fuse::run(const bf::path &mountdir, const vector &fuseOptions) { @@ -296,7 +296,7 @@ void Fuse::stop() { int ret = system(("fusermount -z -u " + _mountdir.native()).c_str()); // "-z" takes care that if the filesystem can't be unmounted right now because something is opened, it will be unmounted as soon as it can be. #endif if (ret != 0) { - LOG(ERROR, "Could not unmount filesystem"); + LOG(ERR, "Could not unmount filesystem"); } } @@ -308,7 +308,7 @@ int Fuse::getattr(const bf::path &path, struct stat *stbuf) { _fs->lstat(path, stbuf); return 0; } catch(const cpputils::AssertFailed &e) { - LOG(ERROR, "AssertFailed in Fuse::getattr: {}", e.what()); + LOG(ERR, "AssertFailed in Fuse::getattr: {}", e.what()); return -EIO; } catch(fspp::fuse::FuseErrnoException &e) { return -e.getErrno(); @@ -339,7 +339,7 @@ int Fuse::fgetattr(const bf::path &path, struct stat *stbuf, fuse_file_info *fil _fs->fstat(fileinfo->fh, stbuf); return 0; } catch(const cpputils::AssertFailed &e) { - LOG(ERROR, "AssertFailed in Fuse::fgetattr: {}", e.what()); + LOG(ERR, "AssertFailed in Fuse::fgetattr: {}", e.what()); return -EIO; } catch(fspp::fuse::FuseErrnoException &e) { return -e.getErrno(); @@ -360,7 +360,7 @@ int Fuse::readlink(const bf::path &path, char *buf, size_t size) { _fs->readSymlink(path, buf, size); return 0; } catch(const cpputils::AssertFailed &e) { - LOG(ERROR, "AssertFailed in Fuse::readlink: {}", e.what()); + LOG(ERR, "AssertFailed in Fuse::readlink: {}", e.what()); return -EIO; } catch (fspp::fuse::FuseErrnoException &e) { return -e.getErrno(); @@ -390,7 +390,7 @@ int Fuse::mkdir(const bf::path &path, mode_t mode) { _fs->mkdir(path, mode, context->uid, context->gid); return 0; } catch(const cpputils::AssertFailed &e) { - LOG(ERROR, "AssertFailed in Fuse::mkdir: {}", e.what()); + LOG(ERR, "AssertFailed in Fuse::mkdir: {}", e.what()); return -EIO; } catch(fspp::fuse::FuseErrnoException &e) { return -e.getErrno(); @@ -411,7 +411,7 @@ int Fuse::unlink(const bf::path &path) { _fs->unlink(path); return 0; } catch(const cpputils::AssertFailed &e) { - LOG(ERROR, "AssertFailed in Fuse::unlink: {}", e.what()); + LOG(ERR, "AssertFailed in Fuse::unlink: {}", e.what()); return -EIO; } catch(fspp::fuse::FuseErrnoException &e) { return -e.getErrno(); @@ -432,7 +432,7 @@ int Fuse::rmdir(const bf::path &path) { _fs->rmdir(path); return 0; } catch(const cpputils::AssertFailed &e) { - LOG(ERROR, "AssertFailed in Fuse::rmdir: {}", e.what()); + LOG(ERR, "AssertFailed in Fuse::rmdir: {}", e.what()); return -EIO; } catch(fspp::fuse::FuseErrnoException &e) { return -e.getErrno(); @@ -454,7 +454,7 @@ int Fuse::symlink(const bf::path &from, const bf::path &to) { _fs->createSymlink(from, to, context->uid, context->gid); return 0; } catch(const cpputils::AssertFailed &e) { - LOG(ERROR, "AssertFailed in Fuse::symlink: {}", e.what()); + LOG(ERR, "AssertFailed in Fuse::symlink: {}", e.what()); return -EIO; } catch(fspp::fuse::FuseErrnoException &e) { return -e.getErrno(); @@ -477,7 +477,7 @@ int Fuse::rename(const bf::path &from, const bf::path &to) { _fs->rename(from, to); return 0; } catch(const cpputils::AssertFailed &e) { - LOG(ERROR, "AssertFailed in Fuse::rename: {}", e.what()); + LOG(ERR, "AssertFailed in Fuse::rename: {}", e.what()); return -EIO; } catch(fspp::fuse::FuseErrnoException &e) { return -e.getErrno(); @@ -508,7 +508,7 @@ int Fuse::chmod(const bf::path &path, mode_t mode) { _fs->chmod(path, mode); return 0; } catch(const cpputils::AssertFailed &e) { - LOG(ERROR, "AssertFailed in Fuse::chmod: {}", e.what()); + LOG(ERR, "AssertFailed in Fuse::chmod: {}", e.what()); return -EIO; } catch (fspp::fuse::FuseErrnoException &e) { return -e.getErrno(); @@ -529,7 +529,7 @@ int Fuse::chown(const bf::path &path, uid_t uid, gid_t gid) { _fs->chown(path, uid, gid); return 0; } catch(const cpputils::AssertFailed &e) { - LOG(ERROR, "AssertFailed in Fuse::chown: {}", e.what()); + LOG(ERR, "AssertFailed in Fuse::chown: {}", e.what()); return -EIO; } catch (fspp::fuse::FuseErrnoException &e) { return -e.getErrno(); @@ -550,7 +550,7 @@ int Fuse::truncate(const bf::path &path, off_t size) { _fs->truncate(path, size); return 0; } catch(const cpputils::AssertFailed &e) { - LOG(ERROR, "AssertFailed in Fuse::truncate: {}", e.what()); + LOG(ERR, "AssertFailed in Fuse::truncate: {}", e.what()); return -EIO; } catch (FuseErrnoException &e) { return -e.getErrno(); @@ -572,7 +572,7 @@ int Fuse::ftruncate(const bf::path &path, off_t size, fuse_file_info *fileinfo) _fs->ftruncate(fileinfo->fh, size); return 0; } catch(const cpputils::AssertFailed &e) { - LOG(ERROR, "AssertFailed in Fuse::ftruncate: {}", e.what()); + LOG(ERR, "AssertFailed in Fuse::ftruncate: {}", e.what()); return -EIO; } catch (FuseErrnoException &e) { return -e.getErrno(); @@ -593,7 +593,7 @@ int Fuse::utimens(const bf::path &path, const timespec times[2]) { _fs->utimens(path, times[0], times[1]); return 0; } catch(const cpputils::AssertFailed &e) { - LOG(ERROR, "AssertFailed in Fuse::utimens: {}", e.what()); + LOG(ERR, "AssertFailed in Fuse::utimens: {}", e.what()); return -EIO; } catch (FuseErrnoException &e) { return -e.getErrno(); @@ -614,7 +614,7 @@ int Fuse::open(const bf::path &path, fuse_file_info *fileinfo) { fileinfo->fh = _fs->openFile(path, fileinfo->flags); return 0; } catch(const cpputils::AssertFailed &e) { - LOG(ERROR, "AssertFailed in Fuse::open: {}", e.what()); + LOG(ERR, "AssertFailed in Fuse::open: {}", e.what()); return -EIO; } catch (FuseErrnoException &e) { return -e.getErrno(); @@ -636,7 +636,7 @@ int Fuse::release(const bf::path &path, fuse_file_info *fileinfo) { _fs->closeFile(fileinfo->fh); return 0; } catch(const cpputils::AssertFailed &e) { - LOG(ERROR, "AssertFailed in Fuse::release: {}", e.what()); + LOG(ERR, "AssertFailed in Fuse::release: {}", e.what()); return -EIO; } catch (FuseErrnoException &e) { return -e.getErrno(); @@ -657,7 +657,7 @@ int Fuse::read(const bf::path &path, char *buf, size_t size, off_t offset, fuse_ try { return _fs->read(fileinfo->fh, buf, size, offset); } catch(const cpputils::AssertFailed &e) { - LOG(ERROR, "AssertFailed in Fuse::read: {}", e.what()); + LOG(ERR, "AssertFailed in Fuse::read: {}", e.what()); return -EIO; } catch (FuseErrnoException &e) { return -e.getErrno(); @@ -679,7 +679,7 @@ int Fuse::write(const bf::path &path, const char *buf, size_t size, off_t offset _fs->write(fileinfo->fh, buf, size, offset); return size; } catch(const cpputils::AssertFailed &e) { - LOG(ERROR, "AssertFailed in Fuse::write: {}", e.what()); + LOG(ERR, "AssertFailed in Fuse::write: {}", e.what()); return -EIO; } catch (FuseErrnoException &e) { return -e.getErrno(); @@ -701,7 +701,7 @@ int Fuse::statfs(const bf::path &path, struct statvfs *fsstat) { _fs->statfs(path, fsstat); return 0; } catch(const cpputils::AssertFailed &e) { - LOG(ERROR, "AssertFailed in Fuse::statfs: {}", e.what()); + LOG(ERR, "AssertFailed in Fuse::statfs: {}", e.what()); return -EIO; } catch (FuseErrnoException &e) { return -e.getErrno(); @@ -723,7 +723,7 @@ int Fuse::flush(const bf::path &path, fuse_file_info *fileinfo) { _fs->flush(fileinfo->fh); return 0; } catch(const cpputils::AssertFailed &e) { - LOG(ERROR, "AssertFailed in Fuse::flush: {}", e.what()); + LOG(ERR, "AssertFailed in Fuse::flush: {}", e.what()); return -EIO; } catch (FuseErrnoException &e) { return -e.getErrno(); @@ -749,7 +749,7 @@ int Fuse::fsync(const bf::path &path, int datasync, fuse_file_info *fileinfo) { } return 0; } catch(const cpputils::AssertFailed &e) { - LOG(ERROR, "AssertFailed in Fuse::fsync: {}", e.what()); + LOG(ERR, "AssertFailed in Fuse::fsync: {}", e.what()); return -EIO; } catch (FuseErrnoException &e) { return -e.getErrno(); @@ -799,7 +799,7 @@ int Fuse::readdir(const bf::path &path, void *buf, fuse_fill_dir_t filler, off_t } return 0; } catch(const cpputils::AssertFailed &e) { - LOG(ERROR, "AssertFailed in Fuse::readdir: {}", e.what()); + LOG(ERR, "AssertFailed in Fuse::readdir: {}", e.what()); return -EIO; } catch (FuseErrnoException &e) { return -e.getErrno(); @@ -853,7 +853,7 @@ int Fuse::access(const bf::path &path, int mask) { _fs->access(path, mask); return 0; } catch(const cpputils::AssertFailed &e) { - LOG(ERROR, "AssertFailed in Fuse::access: {}", e.what()); + LOG(ERR, "AssertFailed in Fuse::access: {}", e.what()); return -EIO; } catch (FuseErrnoException &e) { return -e.getErrno(); @@ -875,7 +875,7 @@ int Fuse::create(const bf::path &path, mode_t mode, fuse_file_info *fileinfo) { fileinfo->fh = _fs->createAndOpenFile(path, mode, context->uid, context->gid); return 0; } catch(const cpputils::AssertFailed &e) { - LOG(ERROR, "AssertFailed in Fuse::create: {}", e.what()); + LOG(ERR, "AssertFailed in Fuse::create: {}", e.what()); return -EIO; } catch (FuseErrnoException &e) { return -e.getErrno(); diff --git a/test/cpp-utils/logging/LoggingLevelTest.cpp b/test/cpp-utils/logging/LoggingLevelTest.cpp index 8a9982e9..513389f2 100644 --- a/test/cpp-utils/logging/LoggingLevelTest.cpp +++ b/test/cpp-utils/logging/LoggingLevelTest.cpp @@ -37,12 +37,12 @@ public: } void EXPECT_ERROR_LOG_ENABLED() { - LOG(ERROR, "My log message"); + LOG(ERR, "My log message"); EXPECT_THAT(mockLogger.capturedLog(), MatchesRegex(".*\\[MockLogger\\].*\\[error\\].*My log message.*")); } void EXPECT_ERROR_LOG_DISABLED() { - LOG(ERROR, "My log message"); + LOG(ERR, "My log message"); EXPECT_EQ("", mockLogger.capturedLog()); } }; @@ -110,7 +110,7 @@ TEST_F(LoggingLevelTest, WARNING_SetAfterSettingLogger) { } TEST_F(LoggingLevelTest, ERROR_SetBeforeSettingLogger) { - setLevel(ERROR); + setLevel(ERR); setLogger(mockLogger.get()); EXPECT_DEBUG_LOG_DISABLED(); EXPECT_INFO_LOG_DISABLED(); @@ -120,7 +120,7 @@ TEST_F(LoggingLevelTest, ERROR_SetBeforeSettingLogger) { TEST_F(LoggingLevelTest, ERROR_SetAfterSettingLogger) { setLogger(mockLogger.get()); - setLevel(ERROR); + setLevel(ERR); EXPECT_DEBUG_LOG_DISABLED(); EXPECT_INFO_LOG_DISABLED(); EXPECT_WARNING_LOG_DISABLED(); diff --git a/test/cpp-utils/logging/LoggingTest.cpp b/test/cpp-utils/logging/LoggingTest.cpp index 8bc3d134..0b63dd2c 100644 --- a/test/cpp-utils/logging/LoggingTest.cpp +++ b/test/cpp-utils/logging/LoggingTest.cpp @@ -59,7 +59,7 @@ TEST_F(LoggingTest, DebugLog) { TEST_F(LoggingTest, ErrorLog) { setLogger(mockLogger.get()); - LOG(ERROR, "My log message"); + LOG(ERR, "My log message"); EXPECT_THAT(mockLogger.capturedLog(), MatchesRegex(".*\\[MockLogger\\].*\\[error\\].*My log message.*")); }