GitLab will be upgraded on June 23rd evening. During the upgrade the service will be unavailable, sorry for the inconvenience.

Commit a1bcd4a7 authored by Olof Svensson's avatar Olof Svensson

Added file logger

parent 7f2627e3
......@@ -24,14 +24,15 @@ __license__ = "MIT"
__date__ = "28/05/2019"
import os
import time
import pprint
import logging
import pathlib
import logging.handlers
from pypushflow import UtilsMongoDb
logger = logging.getLogger('pypushflow')
class Workflow(object):
......@@ -40,24 +41,45 @@ class Workflow(object):
self.listOnErrorActor = []
self.mongoId = UtilsMongoDb.initMongo(name=name)
self.listActorRef = []
self.logger = self.initLogger()
def connectOnError(self, actor):
logger.debug("In Workflow '{0}' connectOnError, actor name {1}".format(,
self.logger.debug("In Workflow '{0}' connectOnError, actor name {1}".format(,
def triggerOnError(self, inData):
logger.debug("In Workflow '{0}' triggerOnError, inData:".format(
self.logger.debug("In Workflow '{0}' triggerOnError, inData:".format(
for onErrorActor in self.listOnErrorActor:
logger.debug("In Workflow '{0}' triggerOnError, triggering actor name {1}".format(,
self.logger.debug("In Workflow '{0}' triggerOnError, triggering actor name {1}".format(,
def getActorPath(self):
return '/' +
def addActorRef(self, actorRef):"Adding actor ref: {0}".format("Adding actor ref: {0}".format(
def getListActorRef(self):
return self.listActorRef
def initLogger(self):
logger = logging.getLogger('pypushflow')
user = os.environ.get("USER", "unknown")
initiator = os.environ.get("PYPUSHFLOW_INITIATOR", "pypushflow")
log_file_dir = pathlib.Path("/tmp/{0}/{1}".format(user, initiator))
if not log_file_dir.exists():
log_file_dir.mkdir(mode=0o755, parents=True)
log_file_path = log_file_dir / "pypushfloww.log"
maxBytes = 1e6
backupCount = 10
fileHandler = logging.handlers.RotatingFileHandler(
log_file_path, maxBytes=maxBytes, backupCount=backupCount)
logFileFormat = '%(asctime)s %(levelname)-8s %(message)s'
formatter = logging.Formatter(logFileFormat)
logger.addHandler(fileHandler)"Logging started")
return logger
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment