2828 AuditorLogStorageInterface ,
2929)
3030
31+ # Base output directory for the auditor
32+ DEFAULT_AUDITOR_OUT_DIR = Path ("logs/auditor" )
33+ DEFAULT_AUDITOR_OUT_DIR .mkdir (parents = True , exist_ok = True )
34+
35+ # Default gpg auditor public key
36+ AUDITOR_PUB_KEY_DIR = Path ("resources/keys" )
37+ AUDITOR_PUB_KEY_FILE = AUDITOR_PUB_KEY_DIR / Path ("llm-router-auditor-pub.asc" )
38+
3139
3240class GPGAuditorLogStorage (AuditorLogStorageInterface ):
3341 """
@@ -46,13 +54,6 @@ class GPGAuditorLogStorage(AuditorLogStorageInterface):
4654 for encryption.
4755 """
4856
49- # Base output directory for the auditor
50- DEFAULT_AUDITOR_OUT_DIR = Path ("logs/auditor" )
51- DEFAULT_AUDITOR_OUT_DIR .mkdir (parents = True , exist_ok = True )
52-
53- AUDITOR_PUB_KEY_DIR = Path ("resources/keys" )
54- AUDITOR_PUB_KEY_FILE = AUDITOR_PUB_KEY_DIR / Path ("llm-router-auditor-pub.asc" )
55-
5657 def __init__ (self ):
5758 """
5859 Create a new GPG‑based audit log storage instance.
@@ -67,14 +68,14 @@ def __init__(self):
6768 """
6869
6970 self ._import_result = None
70- self ._gpg = gnupg .GPG (gnupghome = str (self . AUDITOR_PUB_KEY_DIR ))
71+ self ._gpg = gnupg .GPG (gnupghome = str (AUDITOR_PUB_KEY_DIR ))
7172 self ._gpg .encoding = "utf-8"
7273
73- with self . AUDITOR_PUB_KEY_FILE .open ("r" , encoding = "utf-8" ) as f :
74+ with AUDITOR_PUB_KEY_FILE .open ("r" , encoding = "utf-8" ) as f :
7475 self ._import_result = self ._gpg .import_keys (f .read ())
7576 if not self ._import_result .count :
7677 raise RuntimeError (
77- f"Failed to import public key from { self . AUDITOR_PUB_KEY_FILE } "
78+ f"Failed to import public key from { AUDITOR_PUB_KEY_FILE } "
7879 )
7980
8081 def store_log (self , audit_log , audit_type : str ):
@@ -103,7 +104,7 @@ def store_log(self, audit_log, audit_type: str):
103104 """
104105 date_str = datetime .now ().strftime ("%Y%m%d_%H%M%S.%f" )
105106 out_file_name = f"{ audit_type } __{ date_str } .audit"
106- out_file_path = self . DEFAULT_AUDITOR_OUT_DIR / out_file_name
107+ out_file_path = DEFAULT_AUDITOR_OUT_DIR / out_file_name
107108 with open (out_file_path , "wt" ) as f :
108109 audit_str = json .dumps (audit_log , indent = 2 , ensure_ascii = False )
109110 encrypted_data = self ._gpg .encrypt (
0 commit comments