chore: 移除info类型日志的代码详细追踪信息

master
ternaryop8479 2026-02-14 23:58:00 +08:00
parent 00243a090f
commit 7b2699a74f
1 changed files with 129 additions and 129 deletions

View File

@ -1,9 +1,9 @@
#include "utils/logger.h"
#include <spdlog/spdlog.h>
#include <spdlog/sinks/stdout_color_sinks.h>
#include <spdlog/sinks/basic_file_sink.h>
#include <mutex>
#include <cstring>
#include <mutex>
#include <spdlog/sinks/basic_file_sink.h>
#include <spdlog/sinks/stdout_color_sinks.h>
#include <spdlog/spdlog.h>
namespace are {
@ -53,7 +53,7 @@ void Logger::init(LogLevel min_level) {
logger_impl_ = logger;
initialized_ = true;
} catch (const std::exception& e) {
} catch (const std::exception &e) {
fprintf(stderr, "[ARE] Failed to initialize logger: %s\n", e.what());
}
}
@ -67,22 +67,22 @@ void Logger::shutdown() {
spdlog::shutdown();
logger_impl_.reset();
initialized_ = false;
} catch (const std::exception& e) {
} catch (const std::exception &e) {
fprintf(stderr, "[ARE] Error during logger shutdown: %s\n", e.what());
}
}
void Logger::log(LogLevel level, const char* file, const char* func,
int line, const std::string& message) {
void Logger::log(LogLevel level, const char *file, const char *func,
int line, const std::string &message) {
if (!initialized_) {
init();
}
// Extract filename from full path
const char* filename = file;
const char* last_slash = nullptr;
const char *filename = file;
const char *last_slash = nullptr;
for (const char* p = file; *p; ++p) {
for (const char *p = file; *p; ++p) {
if (*p == '/' || *p == '\\') {
last_slash = p;
}
@ -93,7 +93,7 @@ void Logger::log(LogLevel level, const char* file, const char* func,
}
// Format message with location information
std::string formatted = message + " (" + filename + "-" + func + "():" + std::to_string(line) + ")";
std::string formatted = (level != LogLevel::ARE_LOG_INFO) ? message + " (" + filename + "-" + func + "():" + std::to_string(line) + ")" : message;
try {
auto logger = std::static_pointer_cast<spdlog::logger>(logger_impl_);
@ -118,7 +118,7 @@ void Logger::log(LogLevel level, const char* file, const char* func,
logger->critical(formatted);
break;
}
} catch (const std::exception& e) {
} catch (const std::exception &e) {
fprintf(stderr, "[ARE] Logging error: %s\n", e.what());
}
}
@ -151,7 +151,7 @@ void Logger::set_level(LogLevel level) {
logger->set_level(spdlog::level::critical);
break;
}
} catch (const std::exception& e) {
} catch (const std::exception &e) {
fprintf(stderr, "[ARE] Error setting log level: %s\n", e.what());
}
}