From 7c8642bfbb25ded1eda2894f172b70f1fe361504 Mon Sep 17 00:00:00 2001 From: Maks Snegov Date: Thu, 5 Dec 2019 15:57:59 +0300 Subject: [PATCH] Improve logging a little --- seafile_client/client.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/seafile_client/client.py b/seafile_client/client.py index dcc6faa..59095c7 100644 --- a/seafile_client/client.py +++ b/seafile_client/client.py @@ -1,3 +1,4 @@ +import logging import os import subprocess import time @@ -8,6 +9,10 @@ from .consts import DEFAULT_USERNAME from .misc import create_dir +logging.basicConfig(format="%(asctime)s %(message)s", + level=logging.INFO) + + class SeafileClient: def __init__(self, host: str, port: int, user: str, passwd: str): self.url = f"https://{host}:{port}" @@ -60,7 +65,8 @@ class SeafileClient: if line.startswith('#') or not line.strip(): continue lib, status = line.split(sep='\t', maxsplit=1) - status = status.replace('\t', ' ') + lib = lib.strip() + status = " ".join(status.split()) statuses[lib] = status return statuses @@ -71,7 +77,7 @@ class SeafileClient: cur_status = self.get_status() for folder, state in cur_status.items(): if state != prev_status.get(folder): - print(f"Library {folder}:\t{state}") + logging.info(f"Library {folder}:\t{state}") prev_status[folder] = cur_status[folder]