Added replay ability
This commit is contained in:
+13
-1
@@ -4,7 +4,7 @@ import threading
|
||||
from datetime import datetime, timezone
|
||||
from typing import Any, Dict, List
|
||||
|
||||
from ..environment import discovery_log_path
|
||||
from ..environment import discovery_log_path, replay_path
|
||||
from . import items as itemdb
|
||||
|
||||
|
||||
@@ -16,11 +16,23 @@ def enabled() -> bool:
|
||||
return bool(discovery_log_path())
|
||||
|
||||
|
||||
def _same_file(a: str, b: str) -> bool:
|
||||
try:
|
||||
return os.path.abspath(a) == os.path.abspath(b)
|
||||
except (TypeError, ValueError):
|
||||
return False
|
||||
|
||||
|
||||
def log(record_type: str, **fields):
|
||||
path = discovery_log_path()
|
||||
if not path:
|
||||
return
|
||||
|
||||
# Never clobber the log we are replaying from.
|
||||
source = replay_path()
|
||||
if source and _same_file(path, source):
|
||||
return
|
||||
|
||||
global _initialized
|
||||
with _lock:
|
||||
log_dir = os.path.dirname(path)
|
||||
|
||||
Reference in New Issue
Block a user