# Create log viewer in the front of the web

dev-linux
Ivan Maslov 4 years ago
parent bde44722e9
commit 1adf4b5683

@ -10,7 +10,6 @@ from . import Core
# All functions can return None, Bool or Dict { "IsSuccessful": True } # All functions can return None, Bool or Dict { "IsSuccessful": True }
from .RobotRDPActive import CMDStr # Create CMD Strings from .RobotRDPActive import CMDStr # Create CMD Strings
from .RobotRDPActive import Connector # RDP API from .RobotRDPActive import Connector # RDP API
from .RobotRDPActive import ConnectorExceptions # Exceptions
#from .Settings import Settings #from .Settings import Settings
import importlib import importlib
@ -540,17 +539,10 @@ def GSettingsAutocleaner(inGSettings):
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
from .. import __version__ # Get version from the package from .. import __version__ # Get version from the package
import logging
# Main def for orchestrator # Main def for orchestrator
def Orchestrator(inGSettings): def Orchestrator(inGSettings):
# Test
# 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)
lL = inGSettings["Logger"] lL = inGSettings["Logger"]
lL.addHandler(mHandlerDumpLogList)
#mGlobalDict = Settings.Settings(sys.argv[1]) #mGlobalDict = Settings.Settings(sys.argv[1])
gSettingsDict = inGSettings # Alias for old name in alg gSettingsDict = inGSettings # Alias for old name in alg

@ -293,7 +293,7 @@ def __Create__():
# inModeStr: # inModeStr:
# "BASIC" - create standart configuration # "BASIC" - create standart configuration
from pyOpenRPA.Orchestrator.Utils import LoggerHandlerDumpLogList
def Create(inModeStr="BASIC"): def Create(inModeStr="BASIC"):
if inModeStr=="BASIC": if inModeStr=="BASIC":
lResult = __Create__() # Create settings lResult = __Create__() # Create settings
@ -308,7 +308,7 @@ def Create(inModeStr="BASIC"):
mRobotLogger.setLevel(logging.DEBUG) mRobotLogger.setLevel(logging.DEBUG)
# create the logging file handler # create the logging file handler
mRobotLoggerFH = logging.FileHandler( 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') mRobotLoggerFormatter = logging.Formatter('%(asctime)s - %(levelname)s - %(message)s')
mRobotLoggerFH.setFormatter(mRobotLoggerFormatter) mRobotLoggerFH.setFormatter(mRobotLoggerFormatter)
# add handler to logger object # add handler to logger object
@ -318,4 +318,11 @@ def Create(inModeStr="BASIC"):
handler.setFormatter(mRobotLoggerFormatter) handler.setFormatter(mRobotLoggerFormatter)
mRobotLogger.addHandler(handler) 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 return lResult # return the result dict

@ -1,6 +1,6 @@
from logging import StreamHandler from logging import StreamHandler
class HandlerDumpLog(StreamHandler): class LoggerHandlerDumpLogList(StreamHandler):
def __init__(self, inDict, inKeyStr, inHashKeyStr, inRowCountInt): def __init__(self, inDict, inKeyStr, inHashKeyStr, inRowCountInt):
StreamHandler.__init__(self) StreamHandler.__init__(self)
self.Dict = inDict self.Dict = inDict
@ -11,4 +11,6 @@ class HandlerDumpLog(StreamHandler):
def emit(self, inRecord): def emit(self, inRecord):
inMessageStr = self.format(inRecord) inMessageStr = self.format(inRecord)
self.Dict[self.KeyStr].append(inMessageStr) self.Dict[self.KeyStr].append(inMessageStr)
self.Dict[self.HashKeyStr]=str(int(self.Dict[self.HashKeyStr])+1) 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)
Loading…
Cancel
Save