From 79c858ded6e4e0fc3a5b423973776b313e2cbf10 Mon Sep 17 00:00:00 2001 From: alfrix Date: Tue, 1 Nov 2022 17:54:01 -0300 Subject: [PATCH] functions: logging: use printer_data --- docs/Troubleshooting.md | 13 +++++++++---- ks_includes/functions.py | 1 - screen.py | 9 +++++++-- 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/docs/Troubleshooting.md b/docs/Troubleshooting.md index 58939d51..24420302 100644 --- a/docs/Troubleshooting.md +++ b/docs/Troubleshooting.md @@ -5,12 +5,17 @@ This page will have common problems and common solutions to those problems. The first step to troubleshooting any problem is getting the cause of the error. -* Check for the file `/tmp/KlipperScreen.log` +* Find KlipperScreen.log: -look at the contents by running `cat /tmp/KlipperScreen.log` or grab the file over WinSCP or another sftp program. -This is the most important file, and should be provided if you ask for support. +!!! important + This log file should be provided if you ask for support. -If that file is non-existent, run `journalctl -xe -u KlipperScreen` +Depending on your setup the file could be accesible from the web interface (Mainsail/Fluidd) alongside other logs + +Located at `~/printer_data/logs`or in `/tmp/` if the former doesn't exists. + +If KlipperScreen.log doesn't exist, run `systemctl status KlipperScreen` +(or `journalctl -xe -u KlipperScreen`) Check the file `/var/log/Xorg.0.log` where you can find issues with the X server. diff --git a/ks_includes/functions.py b/ks_includes/functions.py index 0a7f9ebc..bfe22539 100644 --- a/ks_includes/functions.py +++ b/ks_includes/functions.py @@ -157,7 +157,6 @@ def setup_logging(log_file, software_version): stdout_fmt = logging.Formatter( '%(asctime)s [%(filename)s:%(funcName)s()] - %(message)s') stdout_hdlr.setFormatter(stdout_fmt) - fh = listener = None try: if os.path.exists(log_file): diff --git a/screen.py b/screen.py index f0034132..813891df 100644 --- a/screen.py +++ b/screen.py @@ -1123,12 +1123,17 @@ class KlipperScreen(Gtk.Window): def main(): version = functions.get_software_version() parser = argparse.ArgumentParser(description="KlipperScreen - A GUI for Klipper") + homedir = os.path.expanduser("~") + parser.add_argument( - "-c", "--configfile", default="~/KlipperScreen.conf", metavar='', + "-c", "--configfile", default=os.path.join(homedir, "KlipperScreen.conf"), metavar='', help="Location of KlipperScreen configuration file" ) + logdir = os.path.join(homedir, "printer_data", "logs") + if not os.path.exists(logdir): + logdir = "/tmp" parser.add_argument( - "-l", "--logfile", default="/tmp/KlipperScreen.log", metavar='', + "-l", "--logfile", default=os.path.join(logdir, "KlipperScreen.log"), metavar='', help="Location of KlipperScreen logfile output" ) args = parser.parse_args()