Updated with a little infrastructure for allowing daemonization.

This commit is contained in:
Jeremy Fincher 2004-04-18 05:56:31 +00:00
parent 4e5f79ebe5
commit 437afe707c
2 changed files with 20 additions and 16 deletions

View File

@ -46,6 +46,18 @@ installDir = os.path.dirname(os.path.dirname(sys.modules[__name__].__file__))
_srcDir = os.path.join(installDir, 'src')
_pluginsDir = os.path.join(installDir, 'plugins')
###
# version: This should be pretty obvious.
###
version ='0.77.2'
###
# daemonized: This determines whether or not the bot has been daemonized
# (i.e., set to run in the background). Obviously, this defaults
# to False.
###
daemonized = False
###
# allowEval: True if the owner (and only the owner) should be able to eval
# arbitrary Python code. This is specifically *not* a registry
@ -484,13 +496,4 @@ variable."""))
supybot.register('plugins') # This will be used by plugins, but not here.
###############################
###############################
###############################
# DO NOT EDIT PAST THIS POINT #
###############################
###############################
###############################
version ='0.77.2'
# vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78:

View File

@ -82,7 +82,7 @@ class StdoutStreamHandler(BetterStreamHandler):
logging._releaseLock()
def emit(self, record):
if conf.supybot.log.stdout():
if conf.supybot.log.stdout() and not conf.daemonized:
try:
BetterStreamHandler.emit(self, record)
except ValueError, e: # Raised if sys.stdout is closed.
@ -278,12 +278,13 @@ _handler.setLevel(-1)
_logger.addHandler(_handler)
_logger.setLevel(conf.supybot.log.level())
_stdoutHandler = StdoutStreamHandler(sys.stdout)
_formatString = '%(name)s: %(levelname)s %(message)s'
_stdoutFormatter = ColorizedFormatter(_formatString)
_stdoutHandler.setFormatter(_stdoutFormatter)
_stdoutHandler.setLevel(-1)
_logger.addHandler(_stdoutHandler)
if not conf.daemonized:
_stdoutHandler = StdoutStreamHandler(sys.stdout)
_formatString = '%(name)s: %(levelname)s %(message)s'
_stdoutFormatter = ColorizedFormatter(_formatString)
_stdoutHandler.setFormatter(_stdoutFormatter)
_stdoutHandler.setLevel(-1)
_logger.addHandler(_stdoutHandler)
# vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78: