diff options
author | Denys Vlasenko <dvlasenk@redhat.com> | 2011-03-25 00:33:43 +0100 |
---|---|---|
committer | Denys Vlasenko <dvlasenk@redhat.com> | 2011-03-25 00:33:43 +0100 |
commit | 46f706319695dc77d66ab5f7cbc5cbdcad707366 (patch) | |
tree | af8580044be2aac9066c034128ec52c3ce8d198f /src/daemon | |
parent | b42449a7d77e649046a05ca82e2f6fa464bff3ca (diff) | |
download | abrt-46f706319695dc77d66ab5f7cbc5cbdcad707366.tar.gz abrt-46f706319695dc77d66ab5f7cbc5cbdcad707366.tar.xz abrt-46f706319695dc77d66ab5f7cbc5cbdcad707366.zip |
make $ABRT_PROG_PREFIX control whether log messages are prefixed
by abrt-action-foo programs.
abrtd, abrt-server and abrt-handle-crashdump now have option -p
which sets ABRT_PROG_PREFIX=1 for their children and thus makes
them emit program name prefixes.
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
Diffstat (limited to 'src/daemon')
-rw-r--r-- | src/daemon/Daemon.cpp | 9 | ||||
-rw-r--r-- | src/daemon/abrt-action-save-package-data.c | 18 | ||||
-rw-r--r-- | src/daemon/abrt-handle-crashdump.c | 8 | ||||
-rw-r--r-- | src/daemon/abrt-server.c | 4 |
4 files changed, 24 insertions, 15 deletions
diff --git a/src/daemon/Daemon.cpp b/src/daemon/Daemon.cpp index 7e19bcaf..5dd273e7 100644 --- a/src/daemon/Daemon.cpp +++ b/src/daemon/Daemon.cpp @@ -549,6 +549,7 @@ int main(int argc, char** argv) OPT_d = 1 << 1, OPT_s = 1 << 2, OPT_t = 1 << 3, + OPT_p = 1 << 4, }; /* Keep enum above and order of options below in sync! */ struct options program_options[] = { @@ -556,12 +557,11 @@ int main(int argc, char** argv) OPT_BOOL( 'd', NULL, NULL , _("Do not daemonize")), OPT_BOOL( 's', NULL, NULL , _("Log to syslog even with -d")), OPT_INTEGER('t', NULL, &s_timeout, _("Exit after SEC seconds of inactivity")), + OPT_BOOL( 'p', NULL, NULL , _("Add program names to log")), OPT_END() }; unsigned opts = parse_opts(argc, argv, program_options, program_usage_string); - unsetenv("ABRT_SYSLOG"); - putenv(xasprintf("ABRT_VERBOSE=%u", g_verbose)); /* When dbus daemon starts us, it doesn't set PATH * (I saw it set only DBUS_STARTER_ADDRESS and DBUS_STARTER_BUS_TYPE). * In this case, set something sane: @@ -569,7 +569,12 @@ int main(int argc, char** argv) const char *env_path = getenv("PATH"); if (!env_path || !env_path[0]) putenv((char*)"PATH=/usr/sbin:/usr/bin:/sbin:/bin"); + + unsetenv("ABRT_SYSLOG"); + putenv(xasprintf("ABRT_VERBOSE=%u", g_verbose)); msg_prefix = PROGNAME; /* for log(), error_msg() and such */ + if (opts & OPT_p) + putenv((char*)"ABRT_PROG_PREFIX=1"); if (opts & OPT_s) start_syslog_logging(); diff --git a/src/daemon/abrt-action-save-package-data.c b/src/daemon/abrt-action-save-package-data.c index 8f54b96c..34905b60 100644 --- a/src/daemon/abrt-action-save-package-data.c +++ b/src/daemon/abrt-action-save-package-data.c @@ -249,31 +249,27 @@ int main(int argc, char **argv) /* Can't keep these strings/structs static: _() doesn't support that */ const char *program_usage_string = _( - PROGNAME" [options] -d DIR\n" + PROGNAME" [-v] -d DIR\n" "\n" "Query package database and save package name, component, and description" ); enum { OPT_v = 1 << 0, OPT_d = 1 << 1, - OPT_s = 1 << 2, }; /* Keep enum above and order of options below in sync! */ struct options program_options[] = { OPT__VERBOSE(&g_verbose), - OPT_STRING('d', NULL, &dump_dir_name, "DIR", _("Crash dump directory")), - OPT_BOOL( 's', NULL, NULL , _("Log to syslog")), + OPT_STRING('d', NULL, &dump_dir_name, "DIR", _("Dump directory")), OPT_END() }; - unsigned opts = parse_opts(argc, argv, program_options, program_usage_string); + /*unsigned opts =*/ parse_opts(argc, argv, program_options, program_usage_string); putenv(xasprintf("ABRT_VERBOSE=%u", g_verbose)); - //msg_prefix = PROGNAME; - if (opts & OPT_s) - { - openlog(PROGNAME, 0, LOG_DAEMON); - logmode = LOGMODE_SYSLOG; - } + + char *pfx = getenv("ABRT_PROG_PREFIX"); + if (pfx && string_to_bool(pfx)) + msg_prefix = PROGNAME; VERB1 log("Loading settings"); if (load_settings() != 0) diff --git a/src/daemon/abrt-handle-crashdump.c b/src/daemon/abrt-handle-crashdump.c index e7847c5f..3c3e433f 100644 --- a/src/daemon/abrt-handle-crashdump.c +++ b/src/daemon/abrt-handle-crashdump.c @@ -43,7 +43,7 @@ int main(int argc, char **argv) PROGNAME" [-vs]" /*" [-c CONFFILE]"*/ " -d DIR -e EVENT\n" " or: "PROGNAME" [-vs]" /*" [-c CONFFILE]"*/ " [-d DIR] -l[PFX]\n" "\n" - "Handle crash dump according to rules in abrt_event.conf" + "Handles dump directory DIR according to rules in abrt_event.conf" ); enum { OPT_v = 1 << 0, @@ -51,15 +51,17 @@ int main(int argc, char **argv) OPT_d = 1 << 2, OPT_e = 1 << 3, OPT_l = 1 << 4, + OPT_p = 1 << 5, // OPT_c = 1 << ?, }; /* Keep enum above and order of options below in sync! */ struct options program_options[] = { OPT__VERBOSE(&g_verbose), OPT_BOOL( 's', NULL, NULL , _("Log to syslog" )), - OPT_STRING( 'd', NULL, &dump_dir_name, "DIR" , _("Crash dump directory")), + OPT_STRING( 'd', NULL, &dump_dir_name, "DIR" , _("Dump directory")), OPT_STRING( 'e', NULL, &event , "EVENT" , _("Handle EVENT" )), OPT_OPTSTRING('l', NULL, &pfx , "PFX" , _("List possible events [which start with PFX]")), + OPT_BOOL( 'p', NULL, NULL , _("Add program names to log")), // OPT_STRING( 'c', NULL, &conf_filename, "CONFFILE", _("Configuration file" )), OPT_END() }; @@ -69,6 +71,8 @@ int main(int argc, char **argv) putenv(xasprintf("ABRT_VERBOSE=%u", g_verbose)); msg_prefix = PROGNAME; + if (opts & OPT_p) + putenv((char*)"ABRT_PROG_PREFIX=1"); if (opts & OPT_s) { openlog(msg_prefix, 0, LOG_DAEMON); diff --git a/src/daemon/abrt-server.c b/src/daemon/abrt-server.c index 0c45e3e8..9d4a2310 100644 --- a/src/daemon/abrt-server.c +++ b/src/daemon/abrt-server.c @@ -289,18 +289,22 @@ int main(int argc, char **argv) OPT_v = 1 << 0, OPT_u = 1 << 1, OPT_s = 1 << 2, + OPT_p = 1 << 3, }; /* Keep enum above and order of options below in sync! */ struct options program_options[] = { OPT__VERBOSE(&g_verbose), OPT_INTEGER('u', NULL, &client_uid, _("Use UID as client uid")), OPT_BOOL( 's', NULL, NULL , _("Log to syslog")), + OPT_BOOL( 'p', NULL, NULL , _("Add program names to log")), OPT_END() }; unsigned opts = parse_opts(argc, argv, program_options, program_usage_string); putenv(xasprintf("ABRT_VERBOSE=%u", g_verbose)); msg_prefix = xasprintf(PROGNAME"[%u]", getpid()); + if (opts & OPT_p) + putenv((char*)"ABRT_PROG_PREFIX=1"); if (opts & OPT_s) { openlog(msg_prefix, 0, LOG_DAEMON); |