Skip to content
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

Allow to send logs to stdout/stderr #613

Merged
merged 2 commits into from
May 29, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Allow to send logs to stdout/stderr
Currently, we only supported to send logs to the log file,
but we epxected to collect logs through stdout/stderr instead of
the log file when deploying the Kvrocks in the container. We also
upgrade the glog to v0.6.0 since the logs to stdout was supported
after that.
git-hulk committed May 29, 2022
commit 8fed4fb9a216707a3645b2ea6ce6114924aea83d
2 changes: 1 addition & 1 deletion cmake/glog.cmake
Original file line number Diff line number Diff line change
@@ -21,7 +21,7 @@ include(FetchContent)

FetchContent_Declare(glog
GIT_REPOSITORY https://github.com/google/glog
GIT_TAG v0.4.0
GIT_TAG v0.6.0
)

include(cmake/utils.cmake)
9 changes: 5 additions & 4 deletions kvrocks.conf
Original file line number Diff line number Diff line change
@@ -91,10 +91,11 @@ db-name change.me.db
# Note that you must specify a directory here, not a file name.
dir /tmp/kvrocks

# The logs of server will be stored in this directory. If you don't specify
# one directory, by default, we store logs in the working directory that set
# by 'dir' above.
# log-dir /tmp/kvrocks
# You can configure where to store your server logs by the log-dir.
# If you don't specify one, we will use the above `dir` as our default log directory.
# We also can send logs to stdout/stderr is as simple as:
#
# log-dir stdout

# When running daemonized, kvrocks writes a pid file in ${CONFIG_DIR}/kvrocks.pid by
# default. You can specify a custom pid file location here.
11 changes: 10 additions & 1 deletion src/main.cc
Original file line number Diff line number Diff line change
@@ -172,7 +172,16 @@ static void initGoogleLog(const Config *config) {
FLAGS_minloglevel = config->loglevel;
FLAGS_max_log_size = 100;
FLAGS_logbufsecs = 0;
FLAGS_log_dir = config->log_dir;

if (Util::ToLower(config->log_dir) == "stdout") {
for (int level = google::INFO; level <= google::FATAL; level++) {
google::SetLogDestination(level, "");
}
FLAGS_stderrthreshold = google::ERROR;
FLAGS_logtostdout = true;
} else {
FLAGS_log_dir = config->log_dir;
}
}

bool supervisedUpstart() {