-
Notifications
You must be signed in to change notification settings - Fork 106
Morgana future/fix/configuration parsing error mmap log buffer size #2428
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Morgana future/fix/configuration parsing error mmap log buffer size #2428
Conversation
dd475f2
to
ed8f747
Compare
6665ef6
to
11122b7
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A lot of logic was removed with no any comments, just as part of file recreation. Maybe it's better to recreate the PR from #2363 and redo all the changes with small commits with good messages - I affraid we'll just lose some of the logic.
mmap_password=$(get_opt_value "$line" "mmap_password") | ||
|
||
[[ -n "$mmap_log" && -n "$mmap_host" ]] || | ||
error "if mmaps enabled in access log, there have to be mmap_host and mmap_log options" | ||
fi |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please update the wiki as requested in #2313 (comment)
P.S. I see the new wiki page in https://github.com/tempesta-tech/tempesta/wiki/TFW-Logger and we had a discussion on it
logger/test/Makefile
Outdated
@@ -0,0 +1,71 @@ | |||
# Tempesta FW | |||
# | |||
# Copyright (C) 2024 Tempesta Technologies, Inc. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# Copyright (C) 2024 Tempesta Technologies, Inc. | |
# Copyright (C) 2025 Tempesta Technologies, Inc. |
logger/Makefile
Outdated
@@ -21,7 +21,7 @@ CLICKHOUSE_BUILD_DIR := $(CLICKHOUSE_DIR)/build | |||
CLICKHOUSE_REPO_URL := https://github.com/ClickHouse/clickhouse-cpp.git |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please update the copyright year in all the modified files. Git hub hook should do this automatically, so check your settings
logger/Makefile
Outdated
SRCS := tfw_logger.cc mmap_buffer.cc clickhouse.cc tfw_logger_config.cc | ||
OBJS := $(SRCS:.cc=.o) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SRCS := tfw_logger.cc mmap_buffer.cc clickhouse.cc tfw_logger_config.cc | |
OBJS := $(SRCS:.cc=.o) | |
OBJS := $(patsubst %.cc, %.o, $(wildcard *.cc)) |
logger/tfw_logger.cc
Outdated
if (fd < 0) { | ||
spdlog::error("Failed to open device"); | ||
return 1; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bunch of logic is removed, it seems mostly about daemonization, but I'm not sure that only that logic - it's hard to compare the files line by line. It seems due to my comment #2363 (comment) , which is wrong - in some of our projects we use docker, which doesn't need daemon()
, but once we tried to manage with systemctl, we needed the daemonization mode. @althusky can provide more details on this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pid file also removed. By the way, it seems https://github.com/tempesta-tech/escudo/blob/main/manager/main.cc#L73 implements them in a more accurate way, so it could be better to borrow the code from there
logger/tfw_logger_config.hh
Outdated
void override_clickhouse_max_wait(int ms) { clickhouse_.max_wait = std::chrono::milliseconds(ms); } | ||
|
||
private: | ||
fs::path log_path_{"/var/log/tempesta/tfw_logger.log"}; // Log file path |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably it's not a good place for the default path, other defaults live in tfw_logger.cc
logger/tfw_logger_config.hh
Outdated
void override_clickhouse_user(const std::string& user) { clickhouse_.user = user; } | ||
void override_clickhouse_password(const std::string& password) { clickhouse_.password = password; } | ||
void override_clickhouse_max_events(size_t events) { clickhouse_.max_events = events; } | ||
void override_clickhouse_max_wait(int ms) { clickhouse_.max_wait = std::chrono::milliseconds(ms); } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Too wide lines and other coding style violations, e.g. everything in single line
logger/tfw_logger.cc
Outdated
if (!default_config.save_to_file(config_path)) { | ||
throw Except("Failed to create default configuration file"); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need this and TfwLoggerConfig::save_to_file
? We can jsut create a default file and keep in the repo - it will be easier for users to learn from the default file, probably with comments, and we don't need extra C++ programming. At least we do this for Tempesta FW itself
logger/tfw_logger_config.cc
Outdated
if (clickhouse_.max_events == 0) { | ||
throw std::runtime_error("max_events must be greater than 0"); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
even for C++ we usually organize the code to read it from bottom to top, i.e. the calee parse_from_ptree
must be above the caller TfwLoggerConfig::load_from_file
c399c84
to
548ae7b
Compare
- Move all logger-related files to dedicated logger/ directory - Improve project structure organization - No functional changes in this commit
548ae7b
to
cb84d27
Compare
- Move all logger-related files to dedicated logger/ directory - Improve project structure organization - No functional changes in this commit
cb84d27
to
262c2df
Compare
What
This PR introduces a JSON-based configuration system for the Tempesta FW logger daemon with:
Why
The Tempesta logger configuration is currently scattered across multiple parameters, making it hard to manage. A dedicated JSON file provides a cleaner approach that separates logger settings from the main configuration. This structured format improves error handling and simplifies troubleshooting with the new foreground mode.
Links
#2313