Skip to content

Commit

Permalink
Merge pull request #104 from plone/issue_85
Browse files Browse the repository at this point in the history
Try to look up a suitable log file for the ``logtail`` verb
  • Loading branch information
mauritsvanrees authored May 10, 2019
2 parents c1b5474 + 62f7bf1 commit e539531
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
1 change: 1 addition & 0 deletions news/85.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Try to look up a suitable log file for the ``logtail`` verb
18 changes: 18 additions & 0 deletions src/plone/recipe/zope2instance/ctl.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
from zdaemon.zdoptions import ZDOptions
from Zope2.Startup.options import ConditionalSchemaParser
import csv
import logging
import os
import os.path
import pkg_resources
Expand Down Expand Up @@ -967,6 +968,23 @@ def main(args=None):
options.python, options.interpreter, script, options.wsgi
]

# Try to find the log file from the WSGI configuration
# Requires loading the logging configuration from the WSGI config
try:
logging.config.fileConfig(options.wsgi)

# The root logger is the only one we can identify and get
# reliably as we cannot know what the other loggers' names are
root_logger = logging.getLogger()

for handler in root_logger.handlers:
# Try to find a FileHandler and (ab)use its file target
if isinstance(handler, logging.FileHandler):
options.logfile = handler.baseFilename
break
except Exception:
pass # Give up

c = ZopeCmd(options)

# Mix in any additional commands supplied by other packages:
Expand Down

0 comments on commit e539531

Please sign in to comment.