mirror of
https://github.com/thingsboard/thingsboard-gateway
synced 2025-10-26 22:31:42 +08:00
Improvements remote logging configuration processing
This commit is contained in:
16
setup.cfg
16
setup.cfg
@@ -1,16 +0,0 @@
|
||||
[metadata]
|
||||
name = thingsboard-gateway
|
||||
version = 2.2.5
|
||||
description = Thingsboard Gateway for IoT devices.
|
||||
long_description= file: README.md
|
||||
license = Apache Software License (Apache Software License 2.0)
|
||||
url = https://github.com/thingsboard/thingsboard-gateway
|
||||
author = ThingsBoard
|
||||
author_email = info@thingsboard.io
|
||||
|
||||
[options]
|
||||
include_package_data = True
|
||||
python_requires = >=3.5
|
||||
|
||||
[options.package_data]
|
||||
* = config/*
|
||||
@@ -13,10 +13,11 @@
|
||||
# limitations under the License.
|
||||
|
||||
from os import remove, linesep
|
||||
from os.path import exists
|
||||
from os.path import exists, dirname
|
||||
from re import findall
|
||||
from time import time, sleep
|
||||
from logging import getLogger
|
||||
from logging.config import fileConfig
|
||||
from base64 import b64encode, b64decode
|
||||
from simplejson import dumps, loads, dump
|
||||
from yaml import safe_dump
|
||||
@@ -24,6 +25,7 @@ from configparser import ConfigParser
|
||||
|
||||
from thingsboard_gateway.gateway.tb_client import TBClient
|
||||
from thingsboard_gateway.tb_utility.tb_utility import TBUtility
|
||||
from thingsboard_gateway.gateway.tb_logger import TBLoggerHandler
|
||||
|
||||
# pylint: disable=protected-access
|
||||
LOG = getLogger("service")
|
||||
@@ -262,10 +264,14 @@ class RemoteConfigurator:
|
||||
.split(', '))
|
||||
path = args[0][1:-1]
|
||||
LOG.debug("Checking %s...", path)
|
||||
if not exists(path):
|
||||
if not exists(dirname(path)):
|
||||
raise FileNotFoundError
|
||||
with open(logs_conf_file_path, 'w', encoding="UTF-8") as logs:
|
||||
logs.write(self.__new_logs_configuration.replace("NONE", "NOTSET")+"\r\n")
|
||||
fileConfig(logs_config)
|
||||
LOG = getLogger('service')
|
||||
# self.__gateway.remote_handler.deactivate()
|
||||
self.__gateway.remote_handler = TBLoggerHandler(self.__gateway)
|
||||
self.__gateway.main_handler.setLevel(new_logging_level)
|
||||
self.__gateway.main_handler.setTarget(self.__gateway.remote_handler)
|
||||
if new_logging_level == "NOTSET":
|
||||
|
||||
@@ -74,4 +74,4 @@ class TBLoggerHandler(logging.Handler):
|
||||
logger = logging.getLogger(logger_name)
|
||||
handler = logging.StreamHandler(stdout)
|
||||
handler.setFormatter(logging.Formatter('[STREAM ONLY] %(asctime)s - %(levelname)s - [%(filename)s] - %(module)s - %(lineno)d - %(message)s'))
|
||||
logger.addHandler(handler)
|
||||
logger.addHandler(handler)
|
||||
|
||||
Reference in New Issue
Block a user