mirror of
https://github.com/altlinux/gpupdate.git
synced 2025-03-21 18:50:38 +03:00
util.logging.log(): Introduced function to wrap log data
This commit is contained in:
parent
25b1774d49
commit
758421b611
@ -18,11 +18,15 @@
|
||||
|
||||
import json
|
||||
import datetime
|
||||
import logging
|
||||
|
||||
from messages import message_with_code
|
||||
|
||||
|
||||
class encoder(json.JSONEncoder):
|
||||
def default(self, obj):
|
||||
result = super(encoder, self).default(obj)
|
||||
result = super(encoder, self)
|
||||
result = result.default(obj)
|
||||
|
||||
if isinstance(obj, set):
|
||||
result = tuple(obj)
|
||||
@ -52,3 +56,24 @@ class slogm(object):
|
||||
|
||||
return result
|
||||
|
||||
def log(message_code, data=None):
|
||||
mtype = message_code[0]
|
||||
|
||||
if 'I' == mtype:
|
||||
logging.info(slogm(message_with_code(message_code), data))
|
||||
return
|
||||
if 'W' == mtype:
|
||||
logging.warning(slogm(message_with_code(message_code), data))
|
||||
return
|
||||
if 'E' == mtype:
|
||||
logging.error(slogm(message_with_code(message_code), data))
|
||||
return
|
||||
if 'F' == mtype:
|
||||
logging.fatal(slogm(message_with_code(message_code), data))
|
||||
return
|
||||
if 'D' == mtype:
|
||||
logging.debug(slogm(message_with_code(message_code), data))
|
||||
return
|
||||
|
||||
logging.error(slogm(message_with_code(message_code), data))
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user