فهرست منبع

Implemented <channel>_syslog config parameters for process config

Jason R. Coombs 12 سال پیش
والد
کامیت
79fae9768e
4فایلهای تغییر یافته به همراه38 افزوده شده و 6 حذف شده
  1. 20 0
      docs/configuration.rst
  2. 3 6
      docs/logging.rst
  3. 9 0
      supervisor/dispatchers.py
  4. 6 0
      supervisor/options.py

+ 20 - 0
docs/configuration.rst

@@ -843,6 +843,16 @@ where specified.
 
   *Introduced*: 3.0a7
 
+``stdout_syslog``
+
+  If true, stdout will be directed to syslog along with the process name.
+
+  *Default*: False
+
+  *Required*:  No.
+
+  *Introduced*: 3.0b3
+
 ``stderr_logfile``
 
   Put process stderr output in this file unless ``redirect_stderr`` is
@@ -910,6 +920,16 @@ where specified.
 
   *Introduced*: 3.0a7
 
+``stderr_syslog``
+
+  If true, stderr will be directed to syslog along with the process name.
+
+  *Default*: False
+
+  *Required*:  No.
+
+  *Introduced*: 3.0b3
+
 ``environment``
 
   A list of key/value pairs in the form ``KEY=val,KEY2=val2`` that

+ 3 - 6
docs/logging.rst

@@ -134,13 +134,10 @@ The configuration keys that influence child process logging in
 ``[program:x]`` and ``[fcgi-program:x]`` sections are these:
 
 ``redirect_stderr``, ``stdout_logfile``, ``stdout_logfile_maxbytes``,
-``stdout_logfile_backups``, ``stdout_capture_maxbytes``,
+``stdout_logfile_backups``, ``stdout_capture_maxbytes``, ``stdout_syslog``,
 ``stderr_logfile``, ``stderr_logfile_maxbytes``,
-``stderr_logfile_backups`` and ``stderr_capture_maxbytes``.
-
-One may set ``stdout_logfile`` or ``stderr_logfile`` to the
-special string "syslog". In this case, logs will be routed to the
-syslog service instead of being saved to files.
+``stderr_logfile_backups``, ``stderr_capture_maxbytes``, and
+``stderr_syslog``.
 
 ``[eventlistener:x]`` sections may not specify
 ``stdout_capture_maxbytes`` or ``stderr_capture_maxbytes``,

+ 9 - 0
supervisor/dispatchers.py

@@ -1,3 +1,4 @@
+import warnings
 import errno
 from supervisor.medusa.asyncore_25 import compact_traceback
 
@@ -129,6 +130,8 @@ class POutputDispatcher(PDispatcher):
         backups = getattr(config, '%s_logfile_backups' % channel)
         fmt = '%(message)s'
         if logfile == 'syslog':
+            warnings.warn("Specifying 'syslog' for filename is deprecated. "
+                "Use %s_syslog instead." % channel, DeprecationWarning)
             fmt = ' '.join((config.name, fmt))
         self.mainlog = loggers.handle_file(
             config.options.getLogger(),
@@ -138,6 +141,12 @@ class POutputDispatcher(PDispatcher):
             maxbytes=maxbytes,
             backups=backups)
 
+        if getattr(config, '%s_syslog' % channel, False):
+            handler = loggers.SysLogHandler()
+            handler.setFormat(config.name + ' %(message)s')
+            handler.setLevel(self.mainlog.level)
+            loggers.addHandler(handler)
+
     def removelogs(self):
         for log in (self.mainlog, self.capturelog):
             if log is not None:

+ 6 - 0
supervisor/options.py

@@ -850,6 +850,10 @@ class ServerOptions(Options):
                 maxbytes = byte_size(get(section, mb_key, '50MB'))
                 logfiles[mb_key] = maxbytes
 
+                sy_key = '%s_syslog' % k
+                syslog = boolean(get(section, sy_key, False))
+                logfiles[syslog] = syslog
+
                 if lf_val is Automatic and not maxbytes:
                     self.parse_warnings.append(
                         'For [%s], AUTO logging used for %s without '
@@ -873,11 +877,13 @@ class ServerOptions(Options):
                 stdout_events_enabled = stdout_events,
                 stdout_logfile_backups=logfiles['stdout_logfile_backups'],
                 stdout_logfile_maxbytes=logfiles['stdout_logfile_maxbytes'],
+                stdout_syslog=logfiles['stdout_syslog'],
                 stderr_logfile=logfiles['stderr_logfile'],
                 stderr_capture_maxbytes = stderr_cmaxbytes,
                 stderr_events_enabled = stderr_events,
                 stderr_logfile_backups=logfiles['stderr_logfile_backups'],
                 stderr_logfile_maxbytes=logfiles['stderr_logfile_maxbytes'],
+                stderr_syslog=logfiles['stderr_syslog'],
                 stopsignal=stopsignal,
                 stopwaitsecs=stopwaitsecs,
                 stopasgroup=stopasgroup,