48 if (
const char* level = std::getenv(
"LOG_LEVEL")) {
53 if (
const char* async_str = std::getenv(
"LOG_ASYNC")) {
61 if (
const char* buffer = std::getenv(
"LOG_BUFFER_SIZE")) {
66 if (
const char* batch = std::getenv(
"LOG_BATCH_SIZE")) {
71 if (
const char* interval = std::getenv(
"LOG_FLUSH_INTERVAL")) {
78 if (
const char* color = std::getenv(
"LOG_COLOR")) {
83 if (
const char* metrics = std::getenv(
"LOG_METRICS")) {
88 if (
const char* structured = std::getenv(
"LOG_STRUCTURED")) {
93 if (
const char* crash = std::getenv(
"LOG_CRASH_HANDLER")) {
98 if (
const char* queue = std::getenv(
"LOG_MAX_QUEUE_SIZE")) {
103 if (
const char* batch_write = std::getenv(
"LOG_BATCH_WRITING")) {
110 return std::getenv(
"LOG_LEVEL") !=
nullptr ||
111 std::getenv(
"LOG_ASYNC") !=
nullptr ||
112 std::getenv(
"LOG_BUFFER_SIZE") !=
nullptr ||
113 std::getenv(
"LOG_BATCH_SIZE") !=
nullptr ||
114 std::getenv(
"LOG_FLUSH_INTERVAL") !=
nullptr ||
115 std::getenv(
"LOG_COLOR") !=
nullptr ||
116 std::getenv(
"LOG_METRICS") !=
nullptr;
126 std::string level_str(str);
127 std::transform(level_str.begin(), level_str.end(), level_str.begin(), ::tolower);
129 if (level_str ==
"trace")
return log_level::trace;
130 if (level_str ==
"debug")
return log_level::debug;
131 if (level_str ==
"info")
return log_level::info;
132 if (level_str ==
"warn" || level_str ==
"warning")
return log_level::warning;
133 if (level_str ==
"error")
return log_level::error;
134 if (level_str ==
"fatal" || level_str ==
"critical")
return log_level::critical;
136 return log_level::info;
140 std::string value(str);
141 std::transform(value.begin(), value.end(), value.begin(), ::tolower);
142 return value ==
"true" || value ==
"1" || value ==
"yes" || value ==
"on";
145 static std::size_t
parse_size(
const char* str, std::size_t default_value) {
147 return std::stoull(str);
149 return default_value;
Abstract interface for logger configuration strategies.
Configuration strategy based on environment variables.
static log_level parse_log_level(const char *str)
bool is_applicable() const override
Check if this strategy is applicable in the current context.
static bool parse_bool(const char *str)
static std::size_t parse_size(const char *str, std::size_t default_value)
int priority() const override
Get the strategy priority.
void apply(logger_config &config) const override
Apply this strategy to a logger configuration.
std::string get_name() const override
Get the strategy name.
Interface for logger configuration strategies (Strategy Pattern)
Configuration structure for logger with validation.
Configuration structure for logger with validation.
log_level min_level
Minimum log level to process.
std::size_t batch_size
Number of messages per batch write.
bool enable_batch_writing
Enable batch writing mode.
bool async
Enable asynchronous logging.
bool enable_color_output
Enable ANSI color output.
bool enable_metrics
Enable performance metrics collection.
std::chrono::milliseconds flush_interval
Interval between automatic flushes.
std::size_t buffer_size
Internal buffer size in bytes.
bool enable_crash_handler
Enable crash signal handler.
std::size_t max_queue_size
Maximum number of queued messages.
bool enable_structured_logging
Enable structured (JSON) log output.