diff options
author | Rob Austein <sra@hactrn.net> | 2012-08-27 14:46:34 +0000 |
---|---|---|
committer | Rob Austein <sra@hactrn.net> | 2012-08-27 14:46:34 +0000 |
commit | e4c190ad3ef54bd21dfc3adbfe817674beeb0944 (patch) | |
tree | 0bb5a74184267e10c10aa18a444fa5fab9d6f687 /rpkid/rpki/log.py | |
parent | 89fb14819a41ca65d2a2ad90a5ef959ad5623dbd (diff) |
setproctitle hack. Useful with smoketest/yamltest/yamlconf, may need
tweaks to be useful in production. Should be harmless in any case.
svn path=/branches/tk274/; revision=4662
Diffstat (limited to 'rpkid/rpki/log.py')
-rw-r--r-- | rpkid/rpki/log.py | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/rpkid/rpki/log.py b/rpkid/rpki/log.py index ee96dcfb..1f323a36 100644 --- a/rpkid/rpki/log.py +++ b/rpkid/rpki/log.py @@ -3,7 +3,7 @@ Logging facilities for RPKI libraries. $Id$ -Copyright (C) 2009--2011 Internet Systems Consortium ("ISC") +Copyright (C) 2009--2012 Internet Systems Consortium ("ISC") Permission to use, copy, modify, and distribute this software for any purpose with or without fee is hereby granted, provided that the above @@ -32,9 +32,19 @@ OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. """ -import syslog, sys, os, time +import syslog +import sys +import os +import time import traceback as tb +try: + import setproctitle + have_setproctitle = True +except ImportError: + have_setproctitle = False + + ## @var enable_trace # Whether call tracing is enabled. @@ -56,6 +66,12 @@ show_python_ids = False enable_tracebacks = True +## @var use_setproctitle +# Whether to use setproctitle (if available) to change name shown for +# this process in ps listings (etc). + +use_setproctitle = True + tag = "" pid = 0 @@ -70,6 +86,8 @@ def init(ident = "rpki", flags = syslog.LOG_PID, facility = syslog.LOG_DAEMON): global tag, pid tag = ident pid = os.getpid() + if ident and have_setproctitle and use_setproctitle: + setproctitle.setproctitle("%s (%s)" % (ident, os.path.basename(os.getcwd()))) def set_trace(enable): """ |