-
Notifications
You must be signed in to change notification settings - Fork 0
/
log_info.py
44 lines (28 loc) · 1008 Bytes
/
log_info.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
from loguru import logger
from flexget import plugin
from flexget.event import event
from flexget.config_schema import one_or_more
plugin_name = 'log_info'
logger = logger.bind(name=plugin_name)
# version pour flexget 3.
class PluginLogInfo(object):
"""
Write a message (with jinja2 replacement)
to the system logging with level=INFO for accepted entries ::
log_info: <message>
Example::
log_info: a message for the log file !
Example::
log_info: 'download: {{ url }}'
"""
schema = one_or_more({'type': 'string'})
def on_task_output(self, task, config):
if not isinstance(config, list):
config = [config]
test = '--test ' if task.options.test else ''
for entry in task.accepted:
for mes in config:
logger.info(test + entry.render(mes))
@event('plugin.register')
def register_plugin():
plugin.register(PluginLogInfo, plugin_name, api_ver=2)