forked from metin2/server
Rewrote the log initialization functions, logs are now saved in rotating files, implemented configurable log levels
This commit is contained in:
@ -3,7 +3,7 @@ cmake_minimum_required(VERSION 3.8)
|
||||
project(db CXX)
|
||||
|
||||
file(GLOB_RECURSE sources
|
||||
src/*.cpp src/*.h
|
||||
src/*.cpp src/*.h
|
||||
)
|
||||
|
||||
# Add the src directory to the include path
|
||||
@ -11,6 +11,12 @@ include_directories(src)
|
||||
|
||||
add_executable(${PROJECT_NAME} ${sources})
|
||||
|
||||
# Set the default log level based on the build type
|
||||
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
|
||||
message(STATUS "This is a debug build. Log level will be set to 'trace' for target '${PROJECT_NAME}'.")
|
||||
target_compile_definitions(${PROJECT_NAME} PRIVATE SPDLOG_ACTIVE_LEVEL=SPDLOG_LEVEL_TRACE)
|
||||
endif()
|
||||
|
||||
# Find dependencies
|
||||
|
||||
#
|
||||
@ -29,10 +35,6 @@ target_link_libraries(${PROJECT_NAME} PRIVATE libevent::core libevent::extra lib
|
||||
find_package(effolkronium_random CONFIG REQUIRED)
|
||||
target_link_libraries(${PROJECT_NAME} PRIVATE effolkronium_random)
|
||||
|
||||
# fmt
|
||||
find_package(fmt CONFIG REQUIRED)
|
||||
target_link_libraries(${PROJECT_NAME} PRIVATE fmt::fmt)
|
||||
|
||||
#
|
||||
# System-provided dependencies
|
||||
#
|
||||
|
@ -61,6 +61,7 @@ void emergency_sig(int sig)
|
||||
int main()
|
||||
{
|
||||
WriteVersion();
|
||||
log_init();
|
||||
|
||||
#ifdef __FreeBSD__
|
||||
_malloc_options = "A";
|
||||
@ -114,6 +115,8 @@ int main()
|
||||
SPDLOG_DEBUG("WAITING_QUERY_COUNT {}", iCount);
|
||||
}
|
||||
|
||||
log_destroy();
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -151,13 +154,11 @@ int Start()
|
||||
return false;
|
||||
}
|
||||
|
||||
log_set_expiration_days(3);
|
||||
|
||||
if (CConfig::instance().GetValue("LOG_KEEP_DAYS", &tmpValue))
|
||||
if (CConfig::instance().GetValue("LOG_LEVEL", &tmpValue))
|
||||
{
|
||||
tmpValue = std::clamp(tmpValue, 3, 30);
|
||||
log_set_expiration_days(tmpValue);
|
||||
SPDLOG_INFO("Setting log keeping days to {}", tmpValue);
|
||||
SPDLOG_INFO("Setting log level to {}", tmpValue);
|
||||
tmpValue = std::clamp(tmpValue, SPDLOG_LEVEL_TRACE, SPDLOG_LEVEL_OFF);
|
||||
log_set_level(tmpValue);
|
||||
}
|
||||
|
||||
thecore_init(heart_beat, emptybeat);
|
||||
|
Reference in New Issue
Block a user