I am using python-watchdog
to monitor certain paths for changes like add, delete, modify, etc. Along with the time and message information, I want to capture the username of the user who made that change. I was looking at getpass
, and I looked around for a variable within logging itself, but wasnt able to find anything.
Any clues? My watchdog code is below
print 'starting the watcher mate...'
create_log_file()
logging.basicConfig(filename = log_file, level = logging.INFO, format = '%(asctime)s - %(message)s', datefmt = '%Y-%m-%d %H:%M:%S')
path = sys.argv[1] if len(sys.argv) > 1 else '/etc/nginx/'
event_handler = LoggingEventHandler()
observer = Observer()
observer.schedule(event_handler, path, recursive=True)
observer.start()