Start New Discussion within our Software Development Community

Hey all,
I'm new at programming with Python and thru reading different documentation, I built a small program (handler), that I want to accept calls from other scripts to log to file and console, depending on the level passed in. I'm able to get the error message to show up in both locations (console and log file), however, in the log file, one of the messages shows up twice (the 'info' message)...even though it's only being called once....any idea why this might be? Did I set up something wrong? I have included the relevant data here....

************** ******************
import sys, os, getopt, subprocess, logging
from logging import getLogger, Formatter, shutdown
from logging.handlers import RotatingFileHandler

def testLogger ():

myLog = logging.getLogger('myLogger')
handler = logging.handlers.RotatingFileHandler('/tmp/testLogger.log', 'a', 800, 4)
format = logging.Formatter('%(asctime)s %(levelname)-8s %(message)s')

# print to screen
console = logging.StreamHandler()

formatter = logging.Formatter('%(levelname)-8s %(message)s')

return myLog

def myWarning (msg):
logger = testLogger()

def myInfo (msg):
logger = testLogger()

************ *****************
import testLogger



Thanks in advance.

It would be very nice if you would use code tags with your code to preserve the indentations. Otherwise the code is very difficult to read and not too many folks will help.

your Python code here


This article has been dead for over six months. Start a new discussion instead.