summaryrefslogtreecommitdiffstats
path: root/src/daemon/abrt-action-print.cpp
diff options
context:
space:
mode:
authorDenys Vlasenko <dvlasenk@redhat.com>2010-10-20 18:25:26 +0200
committerDenys Vlasenko <dvlasenk@redhat.com>2010-10-20 18:25:26 +0200
commitbfda214e9d634015457a7c5d8e2e1fd26d49a1fb (patch)
treeba2ae953a86e9c7715d9c98b009d72abc06820da /src/daemon/abrt-action-print.cpp
parent451d3d730c7d1ff93031848882e43813ee3c346f (diff)
move logger reporting to a separate program (abrt-action-print)
Usage: abrt-action-print [v] -d DIR Print information about the crash to standard output -v, --verbose be verbose -d DIR Crash dump directory As you can see, it simply writes crash dump information to stdout, not to a file. Logger plugin spawns a child abrt-action-print -d DIR and pipes its output to log file. Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
Diffstat (limited to 'src/daemon/abrt-action-print.cpp')
-rw-r--r--src/daemon/abrt-action-print.cpp83
1 files changed, 83 insertions, 0 deletions
diff --git a/src/daemon/abrt-action-print.cpp b/src/daemon/abrt-action-print.cpp
new file mode 100644
index 00000000..f4d5db1d
--- /dev/null
+++ b/src/daemon/abrt-action-print.cpp
@@ -0,0 +1,83 @@
+/*
+ Write crash dump to stdout in text form.
+
+ Copyright (C) 2009 Zdenek Prikryl (zprikryl@redhat.com)
+ Copyright (C) 2009 RedHat inc.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License along
+ with this program; if not, write to the Free Software Foundation, Inc.,
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+*/
+#include "abrtlib.h"
+#include "parse_options.h"
+#include "crash_types.h"
+#include "abrt_exception.h"
+#include "plugin.h" /* make_description_logger */
+
+#define PROGNAME "abrt-action-print"
+
+static void report_to_stdout(const char *dump_dir_name)
+{
+ struct dump_dir *dd = dd_opendir(dump_dir_name, /*flags:*/ 0);
+ if (!dd)
+ {
+ throw CABRTException(EXCEP_PLUGIN, _("Can't open '%s'"), dump_dir_name);
+ }
+ map_crash_data_t pCrashData;
+ load_crash_data_from_debug_dump(dd, pCrashData);
+ dd_close(dd);
+
+ char *dsc = make_description_logger(pCrashData);
+ fputs(dsc, stdout);
+ free(dsc);
+}
+
+static const char *dump_dir_name = ".";
+
+int main(int argc, char **argv)
+{
+ char *env_verbose = getenv("ABRT_VERBOSE");
+ if (env_verbose)
+ g_verbose = atoi(env_verbose);
+
+ const char *program_usage = _(
+ PROGNAME" [v] -d DIR\n"
+ "\n"
+ "Print information about the crash to standard output");
+ enum {
+ OPT_v = 1 << 0,
+ OPT_d = 1 << 1,
+ };
+ /* 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_END()
+ };
+
+ /*unsigned opts =*/ parse_opts(argc, argv, program_options, program_usage);
+
+ putenv(xasprintf("ABRT_VERBOSE=%u", g_verbose));
+
+ try
+ {
+ report_to_stdout(dump_dir_name);
+ }
+ catch (CABRTException& e)
+ {
+ log("%s", e.what());
+ return 1;
+ }
+
+ return 0;
+}