← Back to team overview

credativ team mailing list archive

[Merge] lp:~credativ/openobject-server/7.0-fixes-syslog into lp:openobject-server

 

mistotebe has proposed merging lp:~credativ/openobject-server/7.0-fixes-syslog into lp:openobject-server.

Requested reviews:
  OpenERP Core Team (openerp)

For more details, see:
https://code.launchpad.net/~credativ/openobject-server/7.0-fixes-syslog/+merge/167023

When setting up multiple servers on a single machine, or just setting up cron workers to run in a separate process, one might want to keep the log streams separate. This has not been possible when logging through syslog. This proposal adds a configuration option to change the syslog facility.
-- 
https://code.launchpad.net/~credativ/openobject-server/7.0-fixes-syslog/+merge/167023
Your team credativ is subscribed to branch lp:~credativ/openobject-server/7.0-fixes-syslog.
=== modified file 'openerp/netsvc.py'
--- openerp/netsvc.py	2013-04-04 13:07:04 +0000
+++ openerp/netsvc.py	2013-06-03 11:34:45 +0000
@@ -102,7 +102,7 @@
         if os.name == 'nt':
             handler = logging.handlers.NTEventLogHandler("%s %s" % (release.description, release.version))
         else:
-            handler = logging.handlers.SysLogHandler('/dev/log')
+            handler = logging.handlers.SysLogHandler('/dev/log', facility=tools.config['syslog_facility'])
         format = '%s %s' % (release.description, release.version) \
                 + ':%(dbname)s:%(levelname)s:%(name)s:%(message)s'
 

=== modified file 'openerp/tools/config.py'
--- openerp/tools/config.py	2013-03-28 09:50:06 +0000
+++ openerp/tools/config.py	2013-06-03 11:34:45 +0000
@@ -172,6 +172,7 @@
         group.add_option("--logfile", dest="logfile", help="file where the server log will be stored")
         group.add_option("--logrotate", dest="logrotate", action="store_true", my_default=False, help="enable logfile rotation")
         group.add_option("--syslog", action="store_true", dest="syslog", my_default=False, help="Send the log to the syslog server")
+        group.add_option("--syslog-facility", dest="syslog_facility", my_default="user", help="Set the facility for outgoing syslog messages")
         group.add_option('--log-handler', action="append", default=DEFAULT_LOG_HANDLER, my_default=DEFAULT_LOG_HANDLER, metavar="PREFIX:LEVEL", help='setup a handler at LEVEL for a given PREFIX. An empty PREFIX indicates the root logger. This option can be repeated. Example: "openerp.orm:DEBUG" or "werkzeug:CRITICAL" (default: ":INFO")')
         group.add_option('--log-request', action="append_const", dest="log_handler", const="openerp.netsvc.rpc.request:DEBUG", help='shortcut for --log-handler=openerp.netsvc.rpc.request:DEBUG')
         group.add_option('--log-response', action="append_const", dest="log_handler", const="openerp.netsvc.rpc.response:DEBUG", help='shortcut for --log-handler=openerp.netsvc.rpc.response:DEBUG')
@@ -366,6 +367,20 @@
         if self.options['pidfile'] in ('None', 'False'):
             self.options['pidfile'] = False
 
+        # convert facility name to number
+        if self.options['syslog']:
+            facility = self.options['syslog_facility'].lower()
+            if facility.isdigit():
+                facility = int(facility)
+            else:
+                import logging.handlers
+                facility = logging.handlers.SysLogHandler.facility_names.get(facility, -1)
+
+            die(facility not in range(24), "unknown syslog facility: '%s'" %
+                    self.options['syslog_facility'])
+
+            self.options['syslog_facility'] = facility
+
         # if defined dont take the configfile value even if the defined value is None
         keys = ['xmlrpc_interface', 'xmlrpc_port', 'longpolling_port',
                 'db_name', 'db_user', 'db_password', 'db_host',
@@ -396,7 +411,7 @@
             'language', 'translate_out', 'translate_in', 'overwrite_existing_translations',
             'debug_mode', 'smtp_ssl', 'load_language',
             'stop_after_init', 'logrotate', 'without_demo', 'xmlrpc', 'syslog',
-            'list_db', 'xmlrpcs', 'proxy_mode',
+            'syslog_facility', 'list_db', 'xmlrpcs', 'proxy_mode',
             'test_file', 'test_enable', 'test_commit', 'test_report_directory',
             'osv_memory_count_limit', 'osv_memory_age_limit', 'max_cron_threads', 'unaccent',
             'workers', 'limit_memory_hard', 'limit_memory_soft', 'limit_time_cpu', 'limit_time_real', 'limit_request', 'gevent'


Follow ups