prod logging
This commit is contained in:
@@ -6,10 +6,10 @@ if DEV:
|
||||
# In dev mode, disable fabric logs but keep stylix and bar logs
|
||||
logger.disable("fabric")
|
||||
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("bar")
|
||||
logger.configure(handlers=[{"sink": lambda msg: print(msg, end=""), "level": "WARNING"}])
|
||||
logger.configure(handlers=[{"sink": sys.stderr, "level": "INFO", "format": "{time} | {level} | {name}:{function}:{line} - {message}"}])
|
||||
|
||||
from fabric import Application
|
||||
from fabric.system_tray.widgets import SystemTray
|
||||
|
||||
@@ -132,8 +132,7 @@ class CalendarService:
|
||||
return
|
||||
|
||||
try:
|
||||
result = subprocess.run(
|
||||
[
|
||||
cmd = [
|
||||
khal_path,
|
||||
"list",
|
||||
"--json",
|
||||
@@ -145,11 +144,16 @@ class CalendarService:
|
||||
"--json",
|
||||
"location",
|
||||
"today",
|
||||
],
|
||||
]
|
||||
logger.info(f"[Calendar] Running command: {' '.join(cmd)}")
|
||||
result = subprocess.run(
|
||||
cmd,
|
||||
capture_output=True,
|
||||
text=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():
|
||||
lines = result.stdout.strip().split("\n")
|
||||
|
||||
@@ -82,12 +82,16 @@ class NotmuchService:
|
||||
|
||||
try:
|
||||
# Get unread email count
|
||||
cmd = [notmuch_path, "count", "tag:unread"]
|
||||
logger.info(f"[Notmuch] Running command: {' '.join(cmd)}")
|
||||
result = subprocess.run(
|
||||
[notmuch_path, "count", "tag:unread"],
|
||||
cmd,
|
||||
capture_output=True,
|
||||
text=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():
|
||||
self.unread_count = int(result.stdout.strip())
|
||||
@@ -146,8 +150,10 @@ class NotmuchWidget(Button):
|
||||
|
||||
try:
|
||||
# Open emacsclient with notmuch function
|
||||
subprocess.Popen([emacsclient_command, "-c", "-e", "(notmuch)"], start_new_session=True)
|
||||
logger.info(f"[Notmuch] Opened notmuch in emacsclient with command: {emacsclient_command}")
|
||||
cmd = [emacsclient_command, "-c", "-e", "(notmuch)"]
|
||||
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:
|
||||
logger.error(f"[Notmuch] Failed to open notmuch in emacsclient '{emacsclient_command}': {e}")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user