Sometimes, I notice the below errors:
python call_Test.py
Traceback (most recent call last):
File "call_Test.py", line 1, in
from Test_Task import TestTask
File
"/cygdrive/d/smoketest/targetflasher/flasher_server/Source/Test_Task.py",
line 5, in
import Logging.logQueueHandler as logq
I wrote some tests for logging module. I use python 2.6 and use the example
as in cookbook
file : Test_Task.py
from threading import Thread
import Logging.logQueueHandler as logq
class TestTask(threading.Thread):
def __init__(self):
pass
def run(self):
t = Thread(target=logq.log, args=("ERROR", "
- Original Message -
> Hi,
>
> I need an efficient way of logging using python.
> My problem statemnt:
> 1. I have multiple processes using the same logging file.
> I need solutions to the following:
> a) If multiple processes are trying to write to the same file, I need
> to prevent that.
You can also add several handlers to your logger with different levels, so that
one Filehandler passes the errors to a log file and StreamHandler passes
messages with a different level to the output stream.
Also by setting the basicConfig of the logger you can format the log messages
so that you
> a) If multiple processes are trying to write to the same file, I need to
> prevent that.
Two things: Use some sort of file locking. You can get the lockfile
module from PyPI. Include at least the process id as one of the
logging fields in your formatter. I haven't don't enough with the
loggin