From 4ca699182801180a17b6370c796813e0a801d852 Mon Sep 17 00:00:00 2001 From: gabime Date: Fri, 22 Dec 2017 18:55:19 +0200 Subject: [PATCH] astyle --- include/spdlog/details/async_log_helper.h | 2 +- include/spdlog/details/file_helper.h | 34 ++++++------- include/spdlog/details/logger_impl.h | 20 ++++---- tests/file_helper.cpp | 58 +++++++++++------------ 4 files changed, 57 insertions(+), 57 deletions(-) diff --git a/include/spdlog/details/async_log_helper.h b/include/spdlog/details/async_log_helper.h index 732236c4..7c3dcf44 100644 --- a/include/spdlog/details/async_log_helper.h +++ b/include/spdlog/details/async_log_helper.h @@ -282,7 +282,7 @@ inline void spdlog::details::async_log_helper::worker_loop() } catch(...) { - _err_handler("Unknown exeption in async logger worker loop."); + _err_handler("Unknown exeption in async logger worker loop."); } } if (_worker_teardown_cb) _worker_teardown_cb(); diff --git a/include/spdlog/details/file_helper.h b/include/spdlog/details/file_helper.h index c131fc9b..fc3ab038 100644 --- a/include/spdlog/details/file_helper.h +++ b/include/spdlog/details/file_helper.h @@ -113,31 +113,31 @@ public: // // "mylog.txt" => ("mylog", ".txt") // "mylog" => ("mylog", "") - // "mylog." => ("mylog.", "") - // "/dir1/dir2/mylog.txt" => ("/dir1/dir2/mylog", ".txt") + // "mylog." => ("mylog.", "") + // "/dir1/dir2/mylog.txt" => ("/dir1/dir2/mylog", ".txt") // // the starting dot in filenames is ignored (hidden files): // - // ".mylog" => (".mylog". "") + // ".mylog" => (".mylog". "") // "my_folder/.mylog" => ("my_folder/.mylog", "") // "my_folder/.mylog.txt" => ("my_folder/.mylog", ".txt") - static std::tuple split_by_extenstion(const spdlog::filename_t& fname) - { - auto ext_index = fname.rfind('.'); + static std::tuple split_by_extenstion(const spdlog::filename_t& fname) + { + auto ext_index = fname.rfind('.'); - // no valid extension found - return whole path and empty string as extension - if (ext_index == filename_t::npos || ext_index == 0 || ext_index == fname.size() - 1) - return std::make_tuple(fname, spdlog::filename_t()); + // no valid extension found - return whole path and empty string as extension + if (ext_index == filename_t::npos || ext_index == 0 || ext_index == fname.size() - 1) + return std::make_tuple(fname, spdlog::filename_t()); - // treat casese like "/etc/rc.d/somelogfile or "/abc/.hiddenfile" - //auto folder_index = fname.find('\\', ext_index); - auto folder_index = fname.rfind(details::os::folder_sep); - if (folder_index != fname.npos && folder_index >= ext_index - 1) - return std::make_tuple(fname, spdlog::filename_t()); + // treat casese like "/etc/rc.d/somelogfile or "/abc/.hiddenfile" + //auto folder_index = fname.find('\\', ext_index); + auto folder_index = fname.rfind(details::os::folder_sep); + if (folder_index != fname.npos && folder_index >= ext_index - 1) + return std::make_tuple(fname, spdlog::filename_t()); - // finally - return a valid base and extnetion tuple - return std::make_tuple(fname.substr(0, ext_index), fname.substr(ext_index)); - } + // finally - return a valid base and extnetion tuple + return std::make_tuple(fname.substr(0, ext_index), fname.substr(ext_index)); + } private: FILE* _fd; filename_t _filename; diff --git a/include/spdlog/details/logger_impl.h b/include/spdlog/details/logger_impl.h index a71ae10f..88044747 100644 --- a/include/spdlog/details/logger_impl.h +++ b/include/spdlog/details/logger_impl.h @@ -98,11 +98,11 @@ inline void spdlog::logger::log(level::level_enum lvl, const char* msg) { _err_handler(ex.what()); } - catch (...) - { - _err_handler("Unknown exception in logger " + _name); - throw; - } + catch (...) + { + _err_handler("Unknown exception in logger " + _name); + throw; + } } template @@ -119,11 +119,11 @@ inline void spdlog::logger::log(level::level_enum lvl, const T& msg) { _err_handler(ex.what()); } - catch (...) - { - _err_handler("Unknown exception in logger " + _name); - throw; - } + catch (...) + { + _err_handler("Unknown exception in logger " + _name); + throw; + } } diff --git a/tests/file_helper.cpp b/tests/file_helper.cpp index ddb4668f..d127c8f0 100644 --- a/tests/file_helper.cpp +++ b/tests/file_helper.cpp @@ -76,42 +76,42 @@ TEST_CASE("file_helper_reopen2", "[file_helper::reopen(false)]]") static void test_split_ext(const char* fname, const char* expect_base, const char* expect_ext) -{ - spdlog::filename_t filename(fname); - spdlog::filename_t expected_base(expect_base); - spdlog::filename_t expected_ext(expect_ext); +{ + spdlog::filename_t filename(fname); + spdlog::filename_t expected_base(expect_base); + spdlog::filename_t expected_ext(expect_ext); #ifdef _WIN32 // replace folder sep - std::replace(filename.begin(), filename.end(), '/', '\\'); - std::replace(expected_base.begin(), expected_base.end(), '/', '\\'); + std::replace(filename.begin(), filename.end(), '/', '\\'); + std::replace(expected_base.begin(), expected_base.end(), '/', '\\'); #endif - spdlog::filename_t basename, ext; - std::tie(basename, ext) = file_helper::split_by_extenstion(filename); - REQUIRE(basename == expected_base); - REQUIRE(ext == expected_ext); + spdlog::filename_t basename, ext; + std::tie(basename, ext) = file_helper::split_by_extenstion(filename); + REQUIRE(basename == expected_base); + REQUIRE(ext == expected_ext); } TEST_CASE("file_helper_split_by_extenstion", "[file_helper::split_by_extenstion()]]") -{ - test_split_ext("mylog.txt", "mylog", ".txt"); - test_split_ext(".mylog.txt", ".mylog", ".txt"); - test_split_ext(".mylog", ".mylog", ""); - test_split_ext("/aaa/bb.d/mylog", "/aaa/bb.d/mylog", ""); - test_split_ext("/aaa/bb.d/mylog.txt", "/aaa/bb.d/mylog", ".txt"); - test_split_ext("aaa/bbb/ccc/mylog.txt", "aaa/bbb/ccc/mylog", ".txt"); - test_split_ext("aaa/bbb/ccc/mylog.", "aaa/bbb/ccc/mylog.", ""); - test_split_ext("aaa/bbb/ccc/.mylog.txt", "aaa/bbb/ccc/.mylog", ".txt"); - test_split_ext("/aaa/bbb/ccc/mylog.txt", "/aaa/bbb/ccc/mylog", ".txt"); - test_split_ext("/aaa/bbb/ccc/.mylog", "/aaa/bbb/ccc/.mylog", ""); - test_split_ext("../mylog.txt", "../mylog", ".txt"); - test_split_ext(".././mylog.txt", ".././mylog", ".txt"); - test_split_ext(".././mylog.txt/xxx", ".././mylog.txt/xxx", ""); - test_split_ext("/mylog.txt", "/mylog", ".txt"); - test_split_ext("//mylog.txt", "//mylog", ".txt"); - test_split_ext("", "", ""); - test_split_ext(".", ".", ""); - test_split_ext("..txt", ".", ".txt"); +{ + test_split_ext("mylog.txt", "mylog", ".txt"); + test_split_ext(".mylog.txt", ".mylog", ".txt"); + test_split_ext(".mylog", ".mylog", ""); + test_split_ext("/aaa/bb.d/mylog", "/aaa/bb.d/mylog", ""); + test_split_ext("/aaa/bb.d/mylog.txt", "/aaa/bb.d/mylog", ".txt"); + test_split_ext("aaa/bbb/ccc/mylog.txt", "aaa/bbb/ccc/mylog", ".txt"); + test_split_ext("aaa/bbb/ccc/mylog.", "aaa/bbb/ccc/mylog.", ""); + test_split_ext("aaa/bbb/ccc/.mylog.txt", "aaa/bbb/ccc/.mylog", ".txt"); + test_split_ext("/aaa/bbb/ccc/mylog.txt", "/aaa/bbb/ccc/mylog", ".txt"); + test_split_ext("/aaa/bbb/ccc/.mylog", "/aaa/bbb/ccc/.mylog", ""); + test_split_ext("../mylog.txt", "../mylog", ".txt"); + test_split_ext(".././mylog.txt", ".././mylog", ".txt"); + test_split_ext(".././mylog.txt/xxx", ".././mylog.txt/xxx", ""); + test_split_ext("/mylog.txt", "/mylog", ".txt"); + test_split_ext("//mylog.txt", "//mylog", ".txt"); + test_split_ext("", "", ""); + test_split_ext(".", ".", ""); + test_split_ext("..txt", ".", ".txt"); }