From 1adf4b5683232a5f1f4c9ff321bb439898f6560f Mon Sep 17 00:00:00 2001 From: Ivan Maslov Date: Thu, 3 Dec 2020 19:09:24 +0300 Subject: [PATCH] # Create log viewer in the front of the web --- Sources/pyOpenRPA/Orchestrator/Orchestrator.py | 10 +--------- Sources/pyOpenRPA/Orchestrator/SettingsTemplate.py | 11 +++++++++-- .../LoggerHandlerDumpLogList.py} | 6 ++++-- Sources/pyOpenRPA/Orchestrator/Utils/__init__.py | 0 4 files changed, 14 insertions(+), 13 deletions(-) rename Sources/pyOpenRPA/Orchestrator/{HandlerList.py => Utils/LoggerHandlerDumpLogList.py} (76%) create mode 100644 Sources/pyOpenRPA/Orchestrator/Utils/__init__.py diff --git a/Sources/pyOpenRPA/Orchestrator/Orchestrator.py b/Sources/pyOpenRPA/Orchestrator/Orchestrator.py index eb55d67b..e06f47b5 100644 --- a/Sources/pyOpenRPA/Orchestrator/Orchestrator.py +++ b/Sources/pyOpenRPA/Orchestrator/Orchestrator.py @@ -10,7 +10,6 @@ from . import Core # All functions can return None, Bool or Dict { "IsSuccessful": True } from .RobotRDPActive import CMDStr # Create CMD Strings from .RobotRDPActive import Connector # RDP API -from .RobotRDPActive import ConnectorExceptions # Exceptions #from .Settings import Settings import importlib @@ -540,17 +539,10 @@ def GSettingsAutocleaner(inGSettings): # # # # # # # # # # # # # # # # # # # # # # # # # # from .. import __version__ # Get version from the package -import logging # Main def for orchestrator def Orchestrator(inGSettings): - - # TEst - from . import HandlerList - mHandlerDumpLogList = HandlerList.HandlerDumpLog( inDict=inGSettings["Client"],inKeyStr="DumpLogList", inHashKeyStr="DumpLogListHashStr",inRowCountInt=100) - mRobotLoggerFormatter = logging.Formatter('%(asctime)s - %(levelname)s - %(message)s') - mHandlerDumpLogList.setFormatter(mRobotLoggerFormatter) + # Test lL = inGSettings["Logger"] - lL.addHandler(mHandlerDumpLogList) #mGlobalDict = Settings.Settings(sys.argv[1]) gSettingsDict = inGSettings # Alias for old name in alg diff --git a/Sources/pyOpenRPA/Orchestrator/SettingsTemplate.py b/Sources/pyOpenRPA/Orchestrator/SettingsTemplate.py index d15fc481..282ca2ff 100644 --- a/Sources/pyOpenRPA/Orchestrator/SettingsTemplate.py +++ b/Sources/pyOpenRPA/Orchestrator/SettingsTemplate.py @@ -293,7 +293,7 @@ def __Create__(): # inModeStr: # "BASIC" - create standart configuration - +from pyOpenRPA.Orchestrator.Utils import LoggerHandlerDumpLogList def Create(inModeStr="BASIC"): if inModeStr=="BASIC": lResult = __Create__() # Create settings @@ -308,7 +308,7 @@ def Create(inModeStr="BASIC"): mRobotLogger.setLevel(logging.DEBUG) # create the logging file handler mRobotLoggerFH = logging.FileHandler( - "Reports\ReportOrchestrator_" + datetime.datetime.now().strftime("%Y_%m_%d") + ".log") + "Reports\\" + datetime.datetime.now().strftime("%Y_%m_%d") + ".log") mRobotLoggerFormatter = logging.Formatter('%(asctime)s - %(levelname)s - %(message)s') mRobotLoggerFH.setFormatter(mRobotLoggerFormatter) # add handler to logger object @@ -318,4 +318,11 @@ def Create(inModeStr="BASIC"): handler.setFormatter(mRobotLoggerFormatter) mRobotLogger.addHandler(handler) ############################################ + mHandlerDumpLogList = LoggerHandlerDumpLogList.LoggerHandlerDumpLogList(inDict=lResult["Client"], + inKeyStr="DumpLogList", + inHashKeyStr="DumpLogListHashStr", + inRowCountInt=lResult["Client"][ + "DumpLogListCountInt"]) + mHandlerDumpLogList.setFormatter(mRobotLoggerFormatter) + mRobotLogger.addHandler(mHandlerDumpLogList) return lResult # return the result dict \ No newline at end of file diff --git a/Sources/pyOpenRPA/Orchestrator/HandlerList.py b/Sources/pyOpenRPA/Orchestrator/Utils/LoggerHandlerDumpLogList.py similarity index 76% rename from Sources/pyOpenRPA/Orchestrator/HandlerList.py rename to Sources/pyOpenRPA/Orchestrator/Utils/LoggerHandlerDumpLogList.py index 72d00b3b..6b23c67d 100644 --- a/Sources/pyOpenRPA/Orchestrator/HandlerList.py +++ b/Sources/pyOpenRPA/Orchestrator/Utils/LoggerHandlerDumpLogList.py @@ -1,6 +1,6 @@ from logging import StreamHandler -class HandlerDumpLog(StreamHandler): +class LoggerHandlerDumpLogList(StreamHandler): def __init__(self, inDict, inKeyStr, inHashKeyStr, inRowCountInt): StreamHandler.__init__(self) self.Dict = inDict @@ -11,4 +11,6 @@ class HandlerDumpLog(StreamHandler): def emit(self, inRecord): inMessageStr = self.format(inRecord) self.Dict[self.KeyStr].append(inMessageStr) - self.Dict[self.HashKeyStr]=str(int(self.Dict[self.HashKeyStr])+1) \ No newline at end of file + self.Dict[self.HashKeyStr]=str(int(self.Dict[self.HashKeyStr])+1) + if len(self.Dict[self.KeyStr])>self.RowCountInt: + self.Dict[self.KeyStr].pop(0) \ No newline at end of file diff --git a/Sources/pyOpenRPA/Orchestrator/Utils/__init__.py b/Sources/pyOpenRPA/Orchestrator/Utils/__init__.py new file mode 100644 index 00000000..e69de29b