Fix mypy errors
This commit is contained in:
parent
9659e516c8
commit
f5863a1c6f
@ -82,18 +82,18 @@ def setup_logging(config: Dict[str, Any]) -> None:
|
|||||||
except ImportError:
|
except ImportError:
|
||||||
raise OperationalException("You need the systemd python package be installed in "
|
raise OperationalException("You need the systemd python package be installed in "
|
||||||
"order to use logging to journald.")
|
"order to use logging to journald.")
|
||||||
handler = JournaldLogHandler()
|
handler_jd = JournaldLogHandler()
|
||||||
# No datetime field for logging into journald, to allow syslog
|
# No datetime field for logging into journald, to allow syslog
|
||||||
# to perform reduction of repeating messages if this is set in the
|
# to perform reduction of repeating messages if this is set in the
|
||||||
# syslog config. The messages should be equal for this.
|
# syslog config. The messages should be equal for this.
|
||||||
handler.setFormatter(Formatter('%(name)s - %(levelname)s - %(message)s'))
|
handler_jd.setFormatter(Formatter('%(name)s - %(levelname)s - %(message)s'))
|
||||||
logging.root.addHandler(handler)
|
logging.root.addHandler(handler_jd)
|
||||||
else:
|
else:
|
||||||
handler = RotatingFileHandler(logfile,
|
handler_rf = RotatingFileHandler(logfile,
|
||||||
maxBytes=1024 * 1024 * 10, # 10Mb
|
maxBytes=1024 * 1024 * 10, # 10Mb
|
||||||
backupCount=10)
|
backupCount=10)
|
||||||
handler.setFormatter(Formatter(LOGFORMAT))
|
handler_rf.setFormatter(Formatter(LOGFORMAT))
|
||||||
logging.root.addHandler(handler)
|
logging.root.addHandler(handler_rf)
|
||||||
|
|
||||||
logging.root.setLevel(logging.INFO if verbosity < 1 else logging.DEBUG)
|
logging.root.setLevel(logging.INFO if verbosity < 1 else logging.DEBUG)
|
||||||
_set_loggers(verbosity, config.get('api_server', {}).get('verbosity', 'info'))
|
_set_loggers(verbosity, config.get('api_server', {}).get('verbosity', 'info'))
|
||||||
|
@ -633,7 +633,7 @@ class RPC:
|
|||||||
}
|
}
|
||||||
return res
|
return res
|
||||||
|
|
||||||
def _rpc_get_logs(self, limit: Optional[int]) -> Dict[str, List]:
|
def _rpc_get_logs(self, limit: Optional[int]) -> Dict[str, Any]:
|
||||||
"""Returns the last X logs"""
|
"""Returns the last X logs"""
|
||||||
if limit:
|
if limit:
|
||||||
buffer = bufferHandler.buffer[-limit:]
|
buffer = bufferHandler.buffer[-limit:]
|
||||||
@ -644,7 +644,7 @@ class RPC:
|
|||||||
|
|
||||||
return {'log_count': len(records), 'logs': records}
|
return {'log_count': len(records), 'logs': records}
|
||||||
|
|
||||||
def _rpc_get_logs_as_string(self, limit: Optional[int]) -> Dict[str, List]:
|
def _rpc_get_logs_as_string(self, limit: Optional[int]) -> List[str]:
|
||||||
"""Returns the last X logs as formatted string (Using the default log format)"""
|
"""Returns the last X logs as formatted string (Using the default log format)"""
|
||||||
if limit:
|
if limit:
|
||||||
buffer = bufferHandler.buffer[-limit:]
|
buffer = bufferHandler.buffer[-limit:]
|
||||||
|
Loading…
Reference in New Issue
Block a user