moved logging
This commit is contained in:
@@ -5,7 +5,7 @@ import subprocess
|
||||
import click
|
||||
from rich.logging import RichHandler
|
||||
|
||||
from restic.console import logger
|
||||
from restic.console import console, logger
|
||||
from restic.loki import send_to_loki
|
||||
|
||||
|
||||
@@ -14,7 +14,9 @@ def get_size(loki_url: str = None):
|
||||
|
||||
result = subprocess.run(cmd, capture_output=True, text=True)
|
||||
data = json.loads(result.stdout)
|
||||
logger.info(f'Total size: {data["total_size"] / 10**6:.2f} MB, {data["snapshots_count"]} snapshots')
|
||||
logger.info(
|
||||
f'Total size: {data["total_size"] / 10**6:.2f} MB, {data["snapshots_count"]} snapshots'
|
||||
)
|
||||
|
||||
if loki_url is not None:
|
||||
send_to_loki(loki_url, result.stdout, backup='size')
|
||||
@@ -23,18 +25,12 @@ def get_size(loki_url: str = None):
|
||||
@click.command()
|
||||
@click.option('--loki-url', type=str, help='Loki URL for logging', envvar='LOKI_URL')
|
||||
def main(loki_url: str = None):
|
||||
get_size(loki_url)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
import logging
|
||||
|
||||
from rich.logging import RichHandler
|
||||
|
||||
from restic.console import console
|
||||
|
||||
logging.basicConfig(
|
||||
level='DEBUG', format='%(message)s', handlers=[RichHandler(markup=True, console=console)]
|
||||
)
|
||||
|
||||
get_size(loki_url)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
||||
Reference in New Issue
Block a user