ActiveState Community

Python Logging Directory

Posted by kenshin on 2009-05-20 00:39
OS: Linux

Hi,
This is my code

#!/usr/bin/env python

import logging, os, time, glob, logging.handlers

path = "/home/g/nani"
DataBase = os.listdir(path)

LOG_FILE = open("/home/g/nslog.log", "w")

my_logger = logging.getLogger('Mylogger')
my_logger.setLevel(logging.INFO)
handler = logging.handlers.RotatingFileHandler(LOG_FILE, maxBytes=20, backupCount=5)
my_logger.addHandler(handler)

for info in DataBase:
file = os.path.join(path, info)
text = open(file, "r")

I want to know when it finishes reading the path if there is changes it should just write it in nslog.log that the file xx.txt has a change it had "something" and it got changed to "something new"

Thanks a lot