]> err.no Git - systemd/commitdiff
journal: introduce log target 'journal' for executed processes
authorLennart Poettering <lennart@poettering.net>
Thu, 5 Jan 2012 22:54:45 +0000 (23:54 +0100)
committerLennart Poettering <lennart@poettering.net>
Fri, 6 Jan 2012 01:48:38 +0000 (02:48 +0100)
man/systemd.conf.xml
man/systemd.exec.xml
src/execute.c
src/execute.h
src/main.c
src/service.c
src/system.conf
src/unit.c

index 56490ef442d7a2626e70d30a5264030245546b07..ba144da8cf89b3f55de6779c99b3d14b5d41ac63 100644 (file)
@@ -81,7 +81,7 @@
                                 <term><varname>ShowStatus=yes</varname></term>
                                 <term><varname>SysVConsole=yes</varname></term>
                                 <term><varname>CrashChVT=1</varname></term>
-                                <term><varname>DefaultStandardOutput=null</varname></term>
+                                <term><varname>DefaultStandardOutput=journal</varname></term>
                                 <term><varname>DefaultStandardError=inherit</varname></term>
 
                                 <listitem><para>Configures various
index 230c4a31f7d3991da64222e3a8a3a76e940690cc..c1ab6b90106bc1b4771ef17cf53b54c5b6b3b488 100644 (file)
                                 <option>tty</option>,
                                 <option>syslog</option>,
                                 <option>kmsg</option>,
+                                <option>journal</option>,
+                                <option>syslog+console</option>,
                                 <option>kmsg+console</option>,
-                                <option>syslog+console</option> or
+                                <option>journal+console</option> or
                                 <option>socket</option>. If set to
                                 <option>inherit</option> the file
                                 descriptor of standard input is
                                 service. <option>kmsg</option>
                                 connects it with the kernel log buffer
                                 which is accessible via
-                                <citerefentry><refentrytitle>dmesg</refentrytitle><manvolnum>1</manvolnum></citerefentry>. <option>syslog+console</option>
-                                and <option>kmsg+console</option> work
+                                <citerefentry><refentrytitle>dmesg</refentrytitle><manvolnum>1</manvolnum></citerefentry>. <option>journal</option>
+                                connects it with the journal which is
+                                accessible via
+                                <citerefentry><refentrytitle>systemd-journalctl</refentrytitle><manvolnum>1</manvolnum></citerefentry>
+                                (Note that everything that is written
+                                to syslog or kmsg is implicitly stored
+                                in the journal as well, those options
+                                are hence supersets of this
+                                one). <option>syslog+console</option>,
+                                <option>journal+console</option> and
+                                <option>kmsg+console</option> work
                                 similarly but copy the output to the
                                 system console as
                                 well. <option>socket</option> connects
                                 in
                                 <citerefentry><refentrytitle>systemd.conf</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
                                 which defaults to
-                                <option>syslog</option>.</para></listitem>
+                                <option>journal</option>.</para></listitem>
                         </varlistentry>
                         <varlistentry>
                                 <term><varname>StandardError=</varname></term>
index a35733259efbdca0a787d99737fe8dedc110c743..cacc8a73c555a4b881255893845c0d32fe7f5455 100644 (file)
@@ -211,7 +211,7 @@ static int connect_logger_as(const ExecContext *context, ExecOutput output, cons
                 !!context->syslog_level_prefix,
                 output == EXEC_OUTPUT_SYSLOG || output == EXEC_OUTPUT_SYSLOG_AND_CONSOLE,
                 output == EXEC_OUTPUT_KMSG || output == EXEC_OUTPUT_KMSG_AND_CONSOLE,
-                output == EXEC_OUTPUT_SYSLOG_AND_CONSOLE || output == EXEC_OUTPUT_KMSG_AND_CONSOLE);
+                output == EXEC_OUTPUT_SYSLOG_AND_CONSOLE || output == EXEC_OUTPUT_KMSG_AND_CONSOLE || output == EXEC_OUTPUT_JOURNAL_AND_CONSOLE);
 
         if (fd != nfd) {
                 r = dup2(fd, nfd) < 0 ? -errno : nfd;
@@ -351,6 +351,8 @@ static int setup_output(const ExecContext *context, int socket_fd, const char *i
         case EXEC_OUTPUT_SYSLOG_AND_CONSOLE:
         case EXEC_OUTPUT_KMSG:
         case EXEC_OUTPUT_KMSG_AND_CONSOLE:
+        case EXEC_OUTPUT_JOURNAL:
+        case EXEC_OUTPUT_JOURNAL_AND_CONSOLE:
                 return connect_logger_as(context, o, ident, STDOUT_FILENO);
 
         case EXEC_OUTPUT_SOCKET:
@@ -404,6 +406,8 @@ static int setup_error(const ExecContext *context, int socket_fd, const char *id
         case EXEC_OUTPUT_SYSLOG_AND_CONSOLE:
         case EXEC_OUTPUT_KMSG:
         case EXEC_OUTPUT_KMSG_AND_CONSOLE:
+        case EXEC_OUTPUT_JOURNAL:
+        case EXEC_OUTPUT_JOURNAL_AND_CONSOLE:
                 return connect_logger_as(context, e, ident, STDERR_FILENO);
 
         case EXEC_OUTPUT_SOCKET:
@@ -1749,10 +1753,10 @@ void exec_context_dump(ExecContext *c, FILE* f, const char *prefix) {
                         prefix, yes_no(c->tty_vhangup),
                         prefix, yes_no(c->tty_vt_disallocate));
 
-        if (c->std_output == EXEC_OUTPUT_SYSLOG || c->std_output == EXEC_OUTPUT_KMSG ||
-            c->std_output == EXEC_OUTPUT_SYSLOG_AND_CONSOLE || c->std_output == EXEC_OUTPUT_KMSG_AND_CONSOLE ||
-            c->std_error == EXEC_OUTPUT_SYSLOG || c->std_error == EXEC_OUTPUT_KMSG ||
-            c->std_error == EXEC_OUTPUT_SYSLOG_AND_CONSOLE || c->std_error == EXEC_OUTPUT_KMSG_AND_CONSOLE)
+        if (c->std_output == EXEC_OUTPUT_SYSLOG || c->std_output == EXEC_OUTPUT_KMSG || c->std_output == EXEC_OUTPUT_JOURNAL ||
+            c->std_output == EXEC_OUTPUT_SYSLOG_AND_CONSOLE || c->std_output == EXEC_OUTPUT_KMSG_AND_CONSOLE || c->std_output == EXEC_OUTPUT_JOURNAL_AND_CONSOLE ||
+            c->std_error == EXEC_OUTPUT_SYSLOG || c->std_error == EXEC_OUTPUT_KMSG || c->std_error == EXEC_OUTPUT_JOURNAL ||
+            c->std_error == EXEC_OUTPUT_SYSLOG_AND_CONSOLE || c->std_error == EXEC_OUTPUT_KMSG_AND_CONSOLE || c->std_error == EXEC_OUTPUT_JOURNAL_AND_CONSOLE)
                 fprintf(f,
                         "%sSyslogFacility: %s\n"
                         "%sSyslogLevel: %s\n",
@@ -2036,6 +2040,8 @@ static const char* const exec_output_table[_EXEC_OUTPUT_MAX] = {
         [EXEC_OUTPUT_SYSLOG_AND_CONSOLE] = "syslog+console",
         [EXEC_OUTPUT_KMSG] = "kmsg",
         [EXEC_OUTPUT_KMSG_AND_CONSOLE] = "kmsg+console",
+        [EXEC_OUTPUT_JOURNAL] = "journal",
+        [EXEC_OUTPUT_JOURNAL_AND_CONSOLE] = "journal+console",
         [EXEC_OUTPUT_SOCKET] = "socket"
 };
 
index 4f05c9fa4b29f9ef4385a3c1ab0e2f4941e60dc2..187e8d22742fc6aefe858608bb3f2703b9720bee 100644 (file)
@@ -74,6 +74,8 @@ typedef enum ExecOutput {
         EXEC_OUTPUT_SYSLOG_AND_CONSOLE,
         EXEC_OUTPUT_KMSG,
         EXEC_OUTPUT_KMSG_AND_CONSOLE,
+        EXEC_OUTPUT_JOURNAL,
+        EXEC_OUTPUT_JOURNAL_AND_CONSOLE,
         EXEC_OUTPUT_SOCKET,
         _EXEC_OUTPUT_MAX,
         _EXEC_OUTPUT_INVALID = -1
index 5c28a6c191c90cbde74df3608fe00b5c1b209452..575e5ea33f0e0c0f460b00699b3c8de0e22a0010 100644 (file)
@@ -77,7 +77,7 @@ static bool arg_mount_auto = true;
 static bool arg_swap_auto = true;
 static char **arg_default_controllers = NULL;
 static char ***arg_join_controllers = NULL;
-static ExecOutput arg_default_std_output = EXEC_OUTPUT_SYSLOG;
+static ExecOutput arg_default_std_output = EXEC_OUTPUT_JOURNAL;
 static ExecOutput arg_default_std_error = EXEC_OUTPUT_INHERIT;
 
 static FILE* serialization = NULL;
@@ -348,9 +348,9 @@ static int parse_proc_cmdline_word(const char *word) {
                          "systemd.log_level=LEVEL                  Log level\n"
                          "systemd.log_color=0|1                    Highlight important log messages\n"
                          "systemd.log_location=0|1                 Include code location in log messages\n"
-                         "systemd.default_standard_output=null|tty|syslog|syslog+console|kmsg|kmsg+console\n"
+                         "systemd.default_standard_output=null|tty|syslog|syslog+console|kmsg|kmsg+console|journal|journal+console\n"
                          "                                         Set default log output for services\n"
-                         "systemd.default_standard_error=null|tty|syslog|syslog+console|kmsg|kmsg+console\n"
+                         "systemd.default_standard_error=null|tty|syslog|syslog+console|kmsg|kmsg+console|journal|journal+console\n"
                          "                                         Set default log error output for services\n");
 
         } else if (streq(word, "quiet")) {
index feecbbe2b6a93ad919e8bf32aec71f2069aefe25..b97114c4be2de6aacaaf04a9a63e463a1283f4d6 100644 (file)
@@ -841,7 +841,7 @@ static int service_load_sysv_path(Service *s, const char *path) {
         s->restart = SERVICE_RESTART_NO;
 
         if (s->meta.manager->sysv_console)
-                s->exec_context.std_output = EXEC_OUTPUT_SYSLOG_AND_CONSOLE;
+                s->exec_context.std_output = EXEC_OUTPUT_JOURNAL_AND_CONSOLE;
 
         s->exec_context.kill_mode = KILL_PROCESS;
 
index 4e050579d5bc11d910abd527dc1fd6de36884135..2d1dd8669b1c3506c0920c98d15553a69225c354 100644 (file)
@@ -21,6 +21,6 @@
 #MountAuto=yes
 #SwapAuto=yes
 #DefaultControllers=cpu
-#DefaultStandardOutput=syslog
+#DefaultStandardOutput=journal
 #DefaultStandardError=inherit
 #JoinControllers=cpu,cpuacct
index b31b92fc24ebb054ae1f898f097aec81e2821db2..8630c3c59d6cc2c9f247c587b5600e43e84b11dc 100644 (file)
@@ -561,11 +561,15 @@ int unit_add_exec_dependencies(Unit *u, ExecContext *c) {
 
         if (c->std_output != EXEC_OUTPUT_KMSG &&
             c->std_output != EXEC_OUTPUT_SYSLOG &&
+            c->std_output != EXEC_OUTPUT_JOURNAL &&
             c->std_output != EXEC_OUTPUT_KMSG_AND_CONSOLE &&
             c->std_output != EXEC_OUTPUT_SYSLOG_AND_CONSOLE &&
+            c->std_output != EXEC_OUTPUT_JOURNAL_AND_CONSOLE &&
             c->std_error != EXEC_OUTPUT_KMSG &&
             c->std_error != EXEC_OUTPUT_SYSLOG &&
+            c->std_error != EXEC_OUTPUT_JOURNAL &&
             c->std_error != EXEC_OUTPUT_KMSG_AND_CONSOLE &&
+            c->std_error != EXEC_OUTPUT_JOURNAL_AND_CONSOLE &&
             c->std_error != EXEC_OUTPUT_SYSLOG_AND_CONSOLE)
                 return 0;