Skip to content

Commit

Permalink
Observe Twisted logs as well
Browse files Browse the repository at this point in the history
The Twisted library doesn't use the regular Python logging framework.
However, a twisted log observer can be added to propagate twisted
log messages to the regular python logging framework, which is what the
rest of ipdevpoll process uses.
  • Loading branch information
lunkwill42 committed Jun 1, 2023
1 parent 440bff6 commit e8416e6
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions python/nav/ipdevpoll/daemon.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import time
import argparse

import twisted
from twisted.internet import reactor
from twisted.internet.defer import maybeDeferred, setDebugging
from twisted.python.failure import Failure
Expand Down Expand Up @@ -412,6 +413,9 @@ def run(self):

def init_logging(self, stderr_only=False):
"""Initializes ipdevpoll logging for the current process."""
observer = twisted.python.log.PythonLoggingObserver()
observer.start()

formatter = ContextFormatter(self.options.pidlog)

logfile_name = None
Expand Down

0 comments on commit e8416e6

Please sign in to comment.