mirror of
https://github.com/Tautulli/Tautulli.git
synced 2025-07-14 01:02:59 -07:00
Remove unused logger functions
This commit is contained in:
parent
5e6126ecbd
commit
6d0fcf0970
1 changed files with 0 additions and 64 deletions
|
@ -18,14 +18,10 @@
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
from future.builtins import str
|
from future.builtins import str
|
||||||
|
|
||||||
from logutils.queue import QueueHandler, QueueListener
|
|
||||||
from logging import handlers
|
from logging import handlers
|
||||||
|
|
||||||
import cherrypy
|
import cherrypy
|
||||||
import contextlib
|
|
||||||
import errno
|
|
||||||
import logging
|
import logging
|
||||||
import multiprocessing
|
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
import sys
|
import sys
|
||||||
|
@ -207,66 +203,6 @@ class PlexTokenFilter(RegexFilter):
|
||||||
return text.replace(token, 16 * '*')
|
return text.replace(token, 16 * '*')
|
||||||
|
|
||||||
|
|
||||||
@contextlib.contextmanager
|
|
||||||
def listener():
|
|
||||||
"""
|
|
||||||
Wrapper that create a QueueListener, starts it and automatically stops it.
|
|
||||||
To be used in a with statement in the main process, for multiprocessing.
|
|
||||||
"""
|
|
||||||
|
|
||||||
global queue
|
|
||||||
|
|
||||||
# Initialize queue if not already done
|
|
||||||
if queue is None:
|
|
||||||
try:
|
|
||||||
queue = multiprocessing.Queue()
|
|
||||||
except OSError as e:
|
|
||||||
queue = False
|
|
||||||
|
|
||||||
# Some machines don't have access to /dev/shm. See
|
|
||||||
# http://stackoverflow.com/questions/2009278 for more information.
|
|
||||||
if e.errno == errno.EACCES:
|
|
||||||
logger.warning('Multiprocess logging disabled, because '
|
|
||||||
'current user cannot map shared memory. You won\'t see any' \
|
|
||||||
'logging generated by the worker processed.')
|
|
||||||
|
|
||||||
# Multiprocess logging may be disabled.
|
|
||||||
if not queue:
|
|
||||||
yield
|
|
||||||
else:
|
|
||||||
queue_listener = QueueListener(queue, *logger.handlers)
|
|
||||||
|
|
||||||
try:
|
|
||||||
queue_listener.start()
|
|
||||||
yield
|
|
||||||
finally:
|
|
||||||
queue_listener.stop()
|
|
||||||
|
|
||||||
|
|
||||||
def initMultiprocessing():
|
|
||||||
"""
|
|
||||||
Remove all handlers and add QueueHandler on top. This should only be called
|
|
||||||
inside a multiprocessing worker process, since it changes the logger
|
|
||||||
completely.
|
|
||||||
"""
|
|
||||||
|
|
||||||
# Multiprocess logging may be disabled.
|
|
||||||
if not queue:
|
|
||||||
return
|
|
||||||
|
|
||||||
# Remove all handlers and add the Queue handler as the only one.
|
|
||||||
for handler in logger.handlers[:]:
|
|
||||||
logger.removeHandler(handler)
|
|
||||||
|
|
||||||
queue_handler = QueueHandler(queue)
|
|
||||||
queue_handler.setLevel(logging.DEBUG)
|
|
||||||
|
|
||||||
logger.addHandler(queue_handler)
|
|
||||||
|
|
||||||
# Change current thread name for log record
|
|
||||||
threading.current_thread().name = multiprocessing.current_process().name
|
|
||||||
|
|
||||||
|
|
||||||
def initLogger(console=False, log_dir=False, verbose=False):
|
def initLogger(console=False, log_dir=False, verbose=False):
|
||||||
"""
|
"""
|
||||||
Setup logging for Tautulli. It uses the logger instance with the name
|
Setup logging for Tautulli. It uses the logger instance with the name
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue