Added rudimentary logging
Only logging creation and deletion of configs for the time being, log goes straight to stdout
This commit is contained in:
parent
c72d079342
commit
ebc430407a
@ -18,6 +18,11 @@ workdir = Path('./work')
|
||||
lockfile = workdir.joinpath('lockfile.lock~')
|
||||
|
||||
|
||||
def log(context_id: str, message) -> None:
|
||||
now = datetime.now()
|
||||
now_string = now.isoformat(' ', 'minutes')
|
||||
print(f'{now_string} - {context_id}: {message}')
|
||||
|
||||
def safe_join(*args) -> Path:
|
||||
'''
|
||||
Similar to flask's own safe_join, but uses Path objects
|
||||
@ -267,6 +272,8 @@ class WireGuard:
|
||||
client_pubkey
|
||||
)
|
||||
server_config.write(sf)
|
||||
log(f'{self.user_name}/{config_id}', f'Created new config')
|
||||
log(f'{self.user_name}/{config_id}', f'IP: {client_ip}')
|
||||
self.wg_updated = True
|
||||
return client_ip
|
||||
|
||||
@ -309,6 +316,7 @@ class WireGuard:
|
||||
[path.unlink() for path in paths]
|
||||
delete_route(client_ip)
|
||||
|
||||
log(f'{self.user_name}/{config_id}', 'Deleted config')
|
||||
self.wg_updated = True
|
||||
|
||||
def update(self) -> None:
|
||||
|
Loading…
x
Reference in New Issue
Block a user