credativ team mailing list archive
-
credativ team
-
Mailing list archive
-
Message #05181
[Merge] lp:~credativ/openobject-server/7.0-fixes-syslog into lp:openobject-server/7.0
mistotebe has proposed merging lp:~credativ/openobject-server/7.0-fixes-syslog into lp:openobject-server/7.0.
Requested reviews:
OpenERP Core Team (openerp)
For more details, see:
https://code.launchpad.net/~credativ/openobject-server/7.0-fixes-syslog/+merge/166994
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/166994
Your team credativ is subscribed to branch lp:~credativ/openobject-server/7.0-fixes-syslog.
=== modified file 'openerp/netsvc.py'
--- openerp/netsvc.py 2013-05-14 10:33:33 +0000
+++ openerp/netsvc.py 2013-06-03 07:52:24 +0000
@@ -161,7 +161,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-01-15 12:40:58 +0000
+++ openerp/tools/config.py 2013-06-03 07:52:24 +0000
@@ -182,6 +182,7 @@
group.add_option("--logfile", dest="logfile", help="file where the server log will be stored")
group.add_option("--no-logrotate", dest="logrotate", action="store_false", my_default=True, help="do not rotate the logfile")
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')
@@ -376,6 +377,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', 'db_name', 'db_user', 'db_password', 'db_host',
'db_port', 'db_template', 'logfile', 'pidfile', 'smtp_port',
@@ -405,7 +420,7 @@
'language', 'translate_out', 'translate_in', 'overwrite_existing_translations',
'debug_mode', 'smtp_ssl', 'load_language',
'stop_after_init', 'logrotate', 'without_demo', 'netrpc', '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'
Follow ups