fix logging
All checks were successful
BlockStorage/repertory/pipeline/head This commit looks good

This commit is contained in:
Scott E. Graves 2024-07-25 20:42:57 -05:00
parent e21fbe84ba
commit cf59db9cee
4 changed files with 21 additions and 15 deletions

View File

@ -178,7 +178,11 @@ void fuse_base::destroy_(void *ptr) {
execute_void_callback(function_name, [&]() { instance().destroy_impl(ptr); });
}
void fuse_base::destroy_impl(void * /* ptr */) { repertory::project_cleanup(); }
void fuse_base::destroy_impl(void * /* ptr */) {
if (not console_enabled_) {
repertory::project_cleanup();
}
}
void fuse_base::display_options(
[[maybe_unused]] std::vector<const char *> args) {
@ -356,7 +360,9 @@ auto fuse_base::init_impl([[maybe_unused]] struct fuse_conn_info *conn,
auto fuse_base::init_impl(struct fuse_conn_info *conn) -> void * {
#endif
utils::file::change_to_process_directory();
if (not console_enabled_) {
repertory::project_initialize();
}
#if defined(__APPLE__)
conn->want |= FUSE_CAP_VOL_RENAME;
@ -413,6 +419,11 @@ auto fuse_base::mount(std::vector<std::string> args) -> int {
#if FUSE_USE_VERSION < 30
umask(0);
#endif
if (not console_enabled_) {
repertory::project_cleanup();
}
ret = fuse_main(
static_cast<int>(fuse_argv.size()),
reinterpret_cast<char **>(const_cast<char **>(fuse_argv.data())),

View File

@ -23,8 +23,8 @@
#include "events/events.hpp"
#include "spdlog/async.h"
#include "spdlog/sinks/stdout_color_sinks.h"
#include "spdlog/spdlog.h"
#include "spdlog/sinks/stdout_color_sinks.h"
namespace repertory {
console_consumer::console_consumer() : console_consumer(event_level::info) {}
@ -56,11 +56,7 @@ console_consumer::console_consumer(event_level level) {
}
};
try {
spdlog::register_logger(
spdlog::create_async<spdlog::sinks::stdout_color_sink_mt>("console"));
} catch (...) {
}
spdlog::create_async<spdlog::sinks::stdout_color_sink_mt>("console");
set_level(level);

View File

@ -58,13 +58,10 @@ logging_consumer::logging_consumer(event_level level,
}
};
try {
spdlog::register_logger(
spdlog::create_async<spdlog::sinks::rotating_file_sink_mt>(
"file", utils::path::combine(log_directory, {"repertory.log"}),
MAX_LOG_FILE_SIZE, MAX_LOG_FILES));
} catch (...) {
}
MAX_LOG_FILE_SIZE, MAX_LOG_FILES);
set_level(level);
E_SUBSCRIBE_ALL(process_event);

View File

@ -47,6 +47,7 @@
namespace repertory {
auto project_initialize() -> bool {
spdlog::drop_all();
spdlog::flush_every(std::chrono::seconds(10));
#if defined(PROJECT_REQUIRE_ALPINE) && !defined(PROJECT_IS_MINGW)
@ -111,5 +112,6 @@ void project_cleanup() {
#if defined(PROJECT_ENABLE_SQLITE)
sqlite3_shutdown();
#endif // defined(PROJECT_ENABLE_SQLITE)
spdlog::shutdown();
}
} // namespace repertory