-
Notifications
You must be signed in to change notification settings - Fork 20
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
Add --quiet flag to suppress log spam #26
Open
KogasaPls
wants to merge
2
commits into
heftig:master
Choose a base branch
from
KogasaPls:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -154,6 +154,9 @@ static bool canary_demote_unknown = FALSE; | |
/* Log to stderr? */ | ||
static bool log_stderr = FALSE; | ||
|
||
/* Suppress logging common status changes? */ | ||
static bool log_quiet = FALSE; | ||
|
||
/* Scheduling policy to use */ | ||
static int sched_policy = SCHED_RR; | ||
|
||
|
@@ -766,11 +769,14 @@ static int process_set_realtime(struct rtkit_user *u, struct process *p, struct | |
goto finish; | ||
} | ||
|
||
syslog(LOG_INFO, "Successfully made thread %llu of process %llu owned by '%s' RT at priority %u.\n", | ||
(unsigned long long) t->pid, | ||
(unsigned long long) p->pid, | ||
get_user_name(u->uid, user, sizeof(user)), | ||
priority); | ||
if (!log_quiet) { | ||
syslog(LOG_INFO, "Successfully made thread %llu of process %llu owned by '%s' RT at priority %u.\n", | ||
(unsigned long long) t->pid, | ||
(unsigned long long) p->pid, | ||
get_user_name(u->uid, user, sizeof(user)), | ||
priority); | ||
} | ||
|
||
|
||
r = 0; | ||
|
||
|
@@ -829,11 +835,13 @@ static int process_set_high_priority(struct rtkit_user *u, struct process *p, st | |
goto finish; | ||
} | ||
|
||
syslog(LOG_INFO, "Successfully made thread %llu of process %llu owned by '%s' high priority at nice level %i.\n", | ||
(unsigned long long) t->pid, | ||
(unsigned long long) p->pid, | ||
get_user_name(u->uid, user, sizeof(user)), | ||
priority); | ||
if (!log_quiet) { | ||
syslog(LOG_INFO, "Successfully made thread %llu of process %llu owned by '%s' high priority at nice level %i.\n", | ||
(unsigned long long) t->pid, | ||
(unsigned long long) p->pid, | ||
get_user_name(u->uid, user, sizeof(user)), | ||
priority); | ||
} | ||
|
||
r = 0; | ||
|
||
|
@@ -857,7 +865,7 @@ static void reset_known(void) { | |
if (verify_process_user(u, p) >= 0 && | ||
verify_process_starttime(p) >= 0 && | ||
verify_thread_starttime(p, t) >= 0) | ||
if (thread_reset(t->pid) >= 0) { | ||
if (thread_reset(t->pid) >= 0 && !log_quiet) { | ||
syslog(LOG_NOTICE, "Successfully demoted thread %llu of process %llu.\n", | ||
(unsigned long long) t->pid, | ||
(unsigned long long) p->pid); | ||
|
@@ -951,7 +959,7 @@ static int reset_all(void) { | |
|
||
if (r == SCHED_FIFO || r == SCHED_RR || | ||
r == (SCHED_FIFO|SCHED_RESET_ON_FORK) || r == (SCHED_RR|SCHED_RESET_ON_FORK)) | ||
if (thread_reset((pid_t) tid) >= 0) { | ||
if (thread_reset((pid_t) tid) >= 0 && !log_quiet) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same issue as above |
||
syslog(LOG_NOTICE, "Successfully demoted thread %llu of process %llu.\n", | ||
(unsigned long long) tid, | ||
(unsigned long long) pid); | ||
|
@@ -1432,10 +1440,12 @@ static DBusHandlerResult dbus_handler(DBusConnection *c, DBusMessage *m, void *u | |
} else | ||
return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; | ||
|
||
syslog(LOG_DEBUG, "Supervising %u threads of %u processes of %u users.\n", | ||
n_total_threads, | ||
n_total_processes, | ||
n_users); | ||
if (!log_quiet) { | ||
syslog(LOG_DEBUG, "Supervising %u threads of %u processes of %u users.\n", | ||
n_total_threads, | ||
n_total_processes, | ||
n_users); | ||
} | ||
|
||
#ifdef HAVE_LIBSYSTEMD | ||
sd_notifyf(0, | ||
|
@@ -1875,6 +1885,7 @@ enum { | |
ARG_CANARY_DEMOTE_ROOT, | ||
ARG_CANARY_DEMOTE_UNKNOWN, | ||
ARG_CANARY_REFUSE_SEC, | ||
ARG_QUIET, | ||
ARG_STDERR, | ||
ARG_INTROSPECT | ||
}; | ||
|
@@ -1905,6 +1916,7 @@ static const struct option long_options[] = { | |
{ "canary-demote-unknown", no_argument, 0, ARG_CANARY_DEMOTE_UNKNOWN }, | ||
{ "canary-refuse-sec", required_argument, 0, ARG_CANARY_REFUSE_SEC }, | ||
{ "stderr", no_argument, 0, ARG_STDERR }, | ||
{ "quiet", no_argument, 0, ARG_QUIET }, | ||
{ "introspect", no_argument, 0, ARG_INTROSPECT }, | ||
{ NULL, 0, 0, 0} | ||
}; | ||
|
@@ -1960,7 +1972,9 @@ static void show_help(const char *exe) { | |
" --no-canary Don't run a canary-based RT watchdog\n\n" | ||
" --no-drop-privileges Don't drop privileges\n" | ||
" --no-chroot Don't chroot\n" | ||
" --quiet Don't log common status changes\n" | ||
" --no-limit-resources Don't limit daemon's resources\n", | ||
|
||
exe, | ||
username, | ||
sp_names[sched_policy], | ||
|
@@ -2222,6 +2236,10 @@ static int parse_command_line(int argc, char *argv[], int *ret) { | |
log_stderr = TRUE; | ||
break; | ||
|
||
case ARG_QUIET: | ||
log_quiet = TRUE; | ||
break; | ||
|
||
case ARG_INTROSPECT: | ||
fputs(introspect_xml, stdout); | ||
*ret = 0; | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
The additional
log_quiet
check here may causen_demoted++
to be erroneously skipped, affecting a log message which is still issued below: