-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #127 from wackerl91/feature/LUNA-67
LUNA-67: Eos integration
- Loading branch information
Showing
27 changed files
with
572 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
from abc import ABCMeta, abstractmethod | ||
|
||
|
||
class AbstractLogger: | ||
__metaclass__ = ABCMeta | ||
|
||
LEVELS = { | ||
'debug': 0, | ||
'info': 1, | ||
'notice': 2, | ||
'warning': 3, | ||
'error': 4, | ||
'severe': 5, | ||
'fatal': 6 | ||
} | ||
|
||
def __init__(self, log_level): | ||
self.log_level = log_level | ||
|
||
@abstractmethod | ||
def debug(self, channel, text): | ||
pass | ||
|
||
@abstractmethod | ||
def info(self, channel, text): | ||
pass | ||
|
||
@abstractmethod | ||
def warning(self, channel, text): | ||
pass | ||
|
||
@abstractmethod | ||
def error(self, channel, text): | ||
pass | ||
|
||
@abstractmethod | ||
def critical(self, channel, text): | ||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
from resources.lib.core.logger.abstractlogger import AbstractLogger | ||
|
||
|
||
class EosLogger(AbstractLogger): | ||
def __init__(self, log_level): | ||
super(EosLogger, self).__init__(log_level) | ||
self.eos_helper = None | ||
|
||
def warning(self, channel, text): | ||
self._log('warning', channel, text) | ||
|
||
def error(self, channel, text): | ||
self._log('error', channel, text) | ||
|
||
def debug(self, channel, text): | ||
self._log('debug', channel, text) | ||
|
||
def info(self, channel, text): | ||
self._log('info', channel, text) | ||
|
||
def critical(self, channel, text): | ||
self._log('critical', channel, text) | ||
|
||
def set_helper(self, eos_helper): | ||
self.eos_helper = eos_helper | ||
|
||
def _log(self, level, channel, text): | ||
if self.eos_helper is not None and self.LEVELS[level] >= self.LEVELS[self.log_level]: | ||
self.eos_helper.log(level, channel, text) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import xbmc | ||
|
||
from resources.lib.core.logger.abstractlogger import AbstractLogger | ||
|
||
|
||
class Logger(AbstractLogger): | ||
def debug(self, channel, text): | ||
xbmc.log(self._format(channel, text), xbmc.LOGDEBUG) | ||
|
||
def info(self, channel, text): | ||
xbmc.log(self._format(channel, text), xbmc.LOGNOTICE) | ||
|
||
def warning(self, channel, text): | ||
xbmc.log(self._format(channel, text), xbmc.LOGWARNING) | ||
|
||
def error(self, channel, text): | ||
xbmc.log(self._format(channel, text), xbmc.LOGERROR) | ||
|
||
def critical(self, channel, text): | ||
xbmc.log(self._format(channel, text), xbmc.LOGSEVERE) | ||
|
||
def _format(self, channel, text): | ||
text = str(text) | ||
return '[%s]: %s' % (channel, text) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
from resources.lib.core.logger.abstractlogger import AbstractLogger | ||
|
||
|
||
class LoggerChain(object): | ||
def __init__(self, prefix): | ||
self.prefix = prefix | ||
self.logger_chain = [] | ||
|
||
def debug(self, message): | ||
for logger in self.logger_chain: | ||
logger.debug(self.prefix, message) | ||
|
||
def info(self, message): | ||
for logger in self.logger_chain: | ||
logger.info(self.prefix, message) | ||
|
||
def warning(self, message): | ||
for logger in self.logger_chain: | ||
logger.warning(self.prefix, message) | ||
|
||
def error(self, message): | ||
for logger in self.logger_chain: | ||
logger.error(self.prefix, message) | ||
|
||
def critical(self, message): | ||
for logger in self.logger_chain: | ||
logger.critical(self.prefix, message) | ||
|
||
def append(self, loggers): | ||
for logger in loggers: | ||
self._append_logger(logger) | ||
|
||
def _append_logger(self, logger): | ||
if isinstance(logger, AbstractLogger): | ||
self.logger_chain.append(logger) | ||
else: | ||
raise AssertionError('Expected to receive an instance of AbstractLogger, got %s instead' % type(logger)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
Oops, something went wrong.