generated from exteraGramPlugins/pluginBase
Message Logger: show logged edits and deletions from telegram-panel [no bump]
Publish plugin / publish (push) Successful in 4s
Publish plugin / publish (push) Successful in 4s
Keeps deleted messages (75% opacity, red icon-pack trash icon), restores logged messages deleted while away, reports deletions, and shows edit history as a mock chat (Edit history in the message menu, Open topic). Message links and history open as any signed-in account with access. Per-master API tokens; chat state synced per checked range with an hour's validity, cached in SQLite with a configurable lifetime. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
80f1d5e55c
commit
9b2f26a845
26 files changed
+2928
-112
No files matched your search
+54
@@ -0,0 +1,54 @@
|
||||
"""Diagnostics mirrored to a file, since this device's logcat surfaces neither
|
||||
Chaquopy stdout nor android_utils.log output.
|
||||
|
||||
The file lives under `get_files_dir()` (app external storage), so it is
|
||||
readable over adb:
|
||||
adb shell cat "/sdcard/Android/data/com.exteragram.messenger/files/exteraGram/exteraGram Files/message_logger/diag.log"
|
||||
"""
|
||||
|
||||
import os
|
||||
import time
|
||||
import traceback
|
||||
|
||||
_MAX_BYTES = 256 * 1024
|
||||
_path = None
|
||||
|
||||
|
||||
def _file():
|
||||
global _path
|
||||
if _path is None:
|
||||
try:
|
||||
from file_utils import get_files_dir
|
||||
|
||||
directory = os.path.join(get_files_dir(), "message_logger")
|
||||
os.makedirs(directory, exist_ok=True)
|
||||
_path = os.path.join(directory, "diag.log")
|
||||
except Exception:
|
||||
_path = ""
|
||||
return _path
|
||||
|
||||
|
||||
def log(message):
|
||||
line = time.strftime("%H:%M:%S ") + str(message)
|
||||
try:
|
||||
from android_utils import log as android_log
|
||||
|
||||
android_log("[message_logger] " + line)
|
||||
except Exception:
|
||||
pass
|
||||
path = _file()
|
||||
if not path:
|
||||
return
|
||||
try:
|
||||
mode = "a"
|
||||
if os.path.exists(path) and os.path.getsize(path) > _MAX_BYTES:
|
||||
mode = "w"
|
||||
with open(path, mode, encoding="utf-8") as handle:
|
||||
handle.write(line + "\n")
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
|
||||
def error(where, exc=None):
|
||||
detail = traceback.format_exc() if exc is not None else ""
|
||||
log(f"ERROR {where}: {exc!r}\n{detail}")
|
||||
Reference in new issue
Block a user