mirror of
https://github.com/jellyfin/jellyfin-kodi.git
synced 2024-12-26 02:36:10 +00:00
Add file and line number to log output.
This commit is contained in:
parent
5df3077a74
commit
0549a8b0ea
1 changed files with 21 additions and 4 deletions
|
@ -1,16 +1,26 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
from __future__ import absolute_import
|
||||||
|
from __future__ import print_function
|
||||||
|
|
||||||
##################################################################################################
|
##################################################################################################
|
||||||
|
|
||||||
|
import os
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
import xbmc
|
import xbmc
|
||||||
|
import xbmcaddon
|
||||||
import database
|
import database
|
||||||
|
|
||||||
from . import window, settings
|
from . import window, settings
|
||||||
|
|
||||||
##################################################################################################
|
##################################################################################################
|
||||||
|
|
||||||
|
__addon__ = xbmcaddon.Addon(id='plugin.video.jellyfin')
|
||||||
|
__pluginpath__ = xbmc.translatePath(__addon__.getAddonInfo('path').decode('utf-8'))
|
||||||
|
|
||||||
|
##################################################################################################
|
||||||
|
|
||||||
|
|
||||||
def config():
|
def config():
|
||||||
|
|
||||||
|
@ -18,6 +28,7 @@ def config():
|
||||||
logger.addHandler(LogHandler())
|
logger.addHandler(LogHandler())
|
||||||
logger.setLevel(logging.DEBUG)
|
logger.setLevel(logging.DEBUG)
|
||||||
|
|
||||||
|
|
||||||
def reset():
|
def reset():
|
||||||
|
|
||||||
for handler in logging.getLogger('JELLYFIN').handlers:
|
for handler in logging.getLogger('JELLYFIN').handlers:
|
||||||
|
@ -59,7 +70,7 @@ class LogHandler(logging.StreamHandler):
|
||||||
string = string.replace(server.encode('utf-8') or "{server}", "{jellyfin-server}")
|
string = string.replace(server.encode('utf-8') or "{server}", "{jellyfin-server}")
|
||||||
|
|
||||||
for token in self.sensitive['Token']:
|
for token in self.sensitive['Token']:
|
||||||
string = string.replace(token.encode('utf-8') or "{token}", "{jellyfin-token}")
|
string = string.replace(token.encode('utf-8') or "{token}", "{jellyfin-token}")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
xbmc.log(string, level=xbmc.LOGNOTICE)
|
xbmc.log(string, level=xbmc.LOGNOTICE)
|
||||||
|
@ -95,9 +106,11 @@ class MyFormatter(logging.Formatter):
|
||||||
# when the logger formatter was instantiated
|
# when the logger formatter was instantiated
|
||||||
format_orig = self._fmt
|
format_orig = self._fmt
|
||||||
|
|
||||||
|
self._gen_rel_path(record)
|
||||||
|
|
||||||
# Replace the original format with one customized by logging level
|
# Replace the original format with one customized by logging level
|
||||||
if record.levelno in (logging.DEBUG, logging.ERROR):
|
#if record.levelno not in [logging.INFO]:
|
||||||
self._fmt = '%(name)s -> %(levelname)s:: %(message)s'
|
self._fmt = '%(name)s -> %(levelname)s::%(relpath)s:%(lineno)s %(message)s'
|
||||||
|
|
||||||
# Call the original formatter class to do the grunt work
|
# Call the original formatter class to do the grunt work
|
||||||
result = logging.Formatter.format(self, record)
|
result = logging.Formatter.format(self, record)
|
||||||
|
@ -106,3 +119,7 @@ class MyFormatter(logging.Formatter):
|
||||||
self._fmt = format_orig
|
self._fmt = format_orig
|
||||||
|
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
def _gen_rel_path(self, record):
|
||||||
|
if record.pathname:
|
||||||
|
record.relpath = os.path.relpath(record.pathname, __pluginpath__)
|
||||||
|
|
Loading…
Reference in a new issue