zmieniono print na logging

zmieniono wyjscie cron z pliku na stdout i stderr
This commit is contained in:
2025-11-03 09:05:45 +01:00
parent 85377e9e1a
commit 820db917ce
6 changed files with 39 additions and 29 deletions

View File

@@ -1,27 +1,28 @@
import datetime
import logging
from config import DOC_NAME, RESULT_DOC
def select_sheet():
"""Generates the sheet name based on the current month and year (MM.YYYY)."""
now = datetime.datetime.now()
sheet_name = now.strftime("%m.%Y")
print(f"📄 Automatycznie wybrano arkusz: {sheet_name}")
logging.info(f"📄 Automatycznie wybrano arkusz: {sheet_name}")
return sheet_name
def get_sheet_data(gsheet_api, sheet_name):
"""Fetches all data from a given sheet."""
print(f"📋 Pobieram dane z arkusza: {sheet_name}")
logging.info(f"📋 Pobieram dane z arkusza: {sheet_name}")
try:
return gsheet_api.get_sheet_data(DOC_NAME, sheet_name)
except Exception as e:
print(f"❌ Błąd podczas pobierania danych z arkusza: {e}")
logging.error(f"❌ Błąd podczas pobierania danych z arkusza: {e}")
return None
def save_results(gsheet_api, sheet_name, processed_rows):
"""Saves the processed rows to the spreadsheet."""
if processed_rows:
print(f"\n\n--- Podsumowanie ---")
print(f"Zebrano {len(processed_rows)} wierszy do przetworzenia.")
logging.info(f"\n\n--- Podsumowanie ---")
logging.info(f"Zebrano {len(processed_rows)} wierszy do przetworzenia.")
gsheet_api.batch_append_unique_rows(RESULT_DOC, sheet_name, processed_rows)
else:
print("\nNie zebrano żadnych danych do przetworzenia.")
logging.info("\nNie zebrano żadnych danych do przetworzenia.")