如何使用 Python 的看门狗 API 添加带有输出消息格式的 "user" 部分?

How to add "user" part with formatting of output message using the watchdog API of Python?

我需要创建一个功能来记录对地图的访问。
代码如下所示:

import sys
import time
import logging
from watchdog.observers import Observer
from watchdog.events import LoggingEventHandler

def FileLogging():
    a = str(input("Give a directory you want to log (vb. D:\\...\\ExampleMap): "))
    print("To close the program press ctrl + c.")
    logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(message)s', datefmt='%H:%M:%S')
    path = a
    event_handler = LoggingEventHandler()  
    observer = Observer()
    observer.schedule(event_handler, path, recursive=True)
    observer.start()

    try:
        while True:
            time.sleep(1)
    except KeyboardInterrupt:
        observer.stop()
    observer.join()

FileLogging()

我的问题是如何才能在 format='%(asctime)s - %(message)s' 中添加 user

换句话说,如何在 map/file 中添加更改内容的人?

我试图在 format='%(asctime)s - %(message)s' 中添加 %(user)s,但这不起作用并给我错误:KeyError: 'user'.

我现在得到的输出消息示例是:

14:02:06 - Modified file: D:\ExampleMap\text1.txt

我想把它变成这样:

14:02:06 - Modified file: D:\ExampleMap\text1.txt - SliQ

无法判断谁修改了文件,因此看门狗模块不支持。