From 5b5ef607eca3e5f72b597f75dae7e415ce117a9f Mon Sep 17 00:00:00 2001 From: "Jose M. Guisado" Date: Thu, 9 Mar 2023 15:14:01 +0100 Subject: ogRest: remove root logger constant Remove unnecesary root logger constant: LOGGER The root logger is used by default when executing: logging.debug() logging.info() logging.warning() ... There is no point in doing: LOGGER = logging.getLogger() # Get root logger LOGGER.debug() # Use root logger --- src/ogRest.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'src/ogRest.py') diff --git a/src/ogRest.py b/src/ogRest.py index 02d3d0c..69620e6 100644 --- a/src/ogRest.py +++ b/src/ogRest.py @@ -20,7 +20,6 @@ from logging.handlers import SysLogHandler from src.restRequest import * -LOGGER = logging.getLogger() class ThreadState(Enum): IDLE = 0 @@ -60,9 +59,9 @@ class restResponse(): return self.msg if response in {ogResponses.OK, ogResponses.IN_PROGRESS}: - LOGGER.debug(self.msg[:ogRest.LOG_LENGTH]) + logging.debug(self.msg[:ogRest.LOG_LENGTH]) else: - LOGGER.warn(self.msg[:ogRest.LOG_LENGTH]) + logging.warn(self.msg[:ogRest.LOG_LENGTH]) self.msg += '\r\n' @@ -281,14 +280,14 @@ class ogRest(): method = request.get_method() URI = request.get_uri() - LOGGER.debug('Incoming request: %s%s', method, URI[:ogRest.LOG_LENGTH]) + logging.debug('Incoming request: %s%s', method, URI[:ogRest.LOG_LENGTH]) if (not "stop" in URI and not "reboot" in URI and not "poweroff" in URI and not "probe" in URI): if self.state == ThreadState.BUSY: - LOGGER.warn('Request has been received ' + logging.warn('Request has been received ' 'while ogClient is busy') response = restResponse(ogResponses.SERVICE_UNAVAILABLE) client.send(response.get()) @@ -306,7 +305,7 @@ class ogRest(): elif "refresh" in URI: self.process_refresh(client) else: - LOGGER.warn('Unsupported request: %s', + logging.warn('Unsupported request: %s', {URI[:ogRest.LOG_LENGTH]}) response = restResponse(ogResponses.BAD_REQUEST) client.send(response.get()) @@ -331,7 +330,7 @@ class ogRest(): elif ("image/create" in URI): self.process_imagecreate(client, request) else: - LOGGER.warn('Unsupported request: %s', + logging.warn('Unsupported request: %s', URI[:ogRest.LOG_LENGTH]) response = restResponse(ogResponses.BAD_REQUEST) client.send(response.get()) -- cgit v1.2.3-18-g5258