prod logging

This commit is contained in:
2025-09-30 00:35:27 +02:00
parent 2d3f97cae1
commit 0be71cfddf
3 changed files with 29 additions and 19 deletions

View File

@@ -6,10 +6,10 @@ if DEV:
# In dev mode, disable fabric logs but keep stylix and bar logs # In dev mode, disable fabric logs but keep stylix and bar logs
logger.disable("fabric") logger.disable("fabric")
else: else:
# In production, disable all debug logs, only keep warnings and errors # In production, disable fabric logs but keep bar logs for debugging
import sys
logger.disable("fabric") logger.disable("fabric")
logger.disable("bar") logger.configure(handlers=[{"sink": sys.stderr, "level": "INFO", "format": "{time} | {level} | {name}:{function}:{line} - {message}"}])
logger.configure(handlers=[{"sink": lambda msg: print(msg, end=""), "level": "WARNING"}])
from fabric import Application from fabric import Application
from fabric.system_tray.widgets import SystemTray from fabric.system_tray.widgets import SystemTray

View File

@@ -132,8 +132,7 @@ class CalendarService:
return return
try: try:
result = subprocess.run( cmd = [
[
khal_path, khal_path,
"list", "list",
"--json", "--json",
@@ -145,11 +144,16 @@ class CalendarService:
"--json", "--json",
"location", "location",
"today", "today",
], ]
logger.info(f"[Calendar] Running command: {' '.join(cmd)}")
result = subprocess.run(
cmd,
capture_output=True, capture_output=True,
text=True, text=True,
check=True, check=True,
) )
logger.info(f"[Calendar] Command stdout: {result.stdout[:200]}...")
logger.info(f"[Calendar] Command stderr: {result.stderr[:200]}...")
if result.stdout.strip(): if result.stdout.strip():
lines = result.stdout.strip().split("\n") lines = result.stdout.strip().split("\n")

View File

@@ -82,12 +82,16 @@ class NotmuchService:
try: try:
# Get unread email count # Get unread email count
cmd = [notmuch_path, "count", "tag:unread"]
logger.info(f"[Notmuch] Running command: {' '.join(cmd)}")
result = subprocess.run( result = subprocess.run(
[notmuch_path, "count", "tag:unread"], cmd,
capture_output=True, capture_output=True,
text=True, text=True,
check=True, check=True,
) )
logger.info(f"[Notmuch] Command stdout: '{result.stdout.strip()}'")
logger.info(f"[Notmuch] Command stderr: '{result.stderr.strip()}'")
if result.stdout.strip(): if result.stdout.strip():
self.unread_count = int(result.stdout.strip()) self.unread_count = int(result.stdout.strip())
@@ -146,8 +150,10 @@ class NotmuchWidget(Button):
try: try:
# Open emacsclient with notmuch function # Open emacsclient with notmuch function
subprocess.Popen([emacsclient_command, "-c", "-e", "(notmuch)"], start_new_session=True) cmd = [emacsclient_command, "-c", "-e", "(notmuch)"]
logger.info(f"[Notmuch] Opened notmuch in emacsclient with command: {emacsclient_command}") logger.info(f"[Notmuch] Running emacsclient command: {' '.join(cmd)}")
subprocess.Popen(cmd, start_new_session=True)
logger.info(f"[Notmuch] Successfully started emacsclient process")
except Exception as e: except Exception as e:
logger.error(f"[Notmuch] Failed to open notmuch in emacsclient '{emacsclient_command}': {e}") logger.error(f"[Notmuch] Failed to open notmuch in emacsclient '{emacsclient_command}': {e}")