# 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 }
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

@ -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

@ -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)
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