Updated log names. Should be easier to find if you forget to delete old logs. Now just called fenrir.log, we don't tend to need to have multiple logs anyway.
This commit is contained in:
@@ -736,7 +736,7 @@ send_fenrir_command("setting set speech#rate=0.9")
|
|||||||
|
|
||||||
**Commands not working:**
|
**Commands not working:**
|
||||||
- Verify `enable_command_remote=True` in settings
|
- Verify `enable_command_remote=True` in settings
|
||||||
- Check Fenrir debug logs: `/var/log/fenrir.log`
|
- Check Fenrir debug logs: `/tmp/fenrir.log`
|
||||||
- Test with simple command: `echo "command interrupt" | socat - UNIX-CLIENT:/tmp/fenrirscreenreader-daemon.sock`
|
- Test with simple command: `echo "command interrupt" | socat - UNIX-CLIENT:/tmp/fenrirscreenreader-daemon.sock`
|
||||||
|
|
||||||
## Command Line Options
|
## Command Line Options
|
||||||
|
|||||||
@@ -3,13 +3,13 @@ https://git.stormux.org/storm/fenrir/issues
|
|||||||
|
|
||||||
For bugs, please provide a debug file that shows the issue.
|
For bugs, please provide a debug file that shows the issue.
|
||||||
How to create a debug file:
|
How to create a debug file:
|
||||||
1. first delete old stuff:
|
1. start fenrir in debug mode
|
||||||
sudo rm /var/log/fenrir.log
|
|
||||||
2. start fenrir in debug mode
|
|
||||||
sudo fenrir -d
|
sudo fenrir -d
|
||||||
<do your stuff>
|
<do your stuff>
|
||||||
3.
|
2.
|
||||||
stop fenrir (fenrirKey + q)
|
stop fenrir (fenrirKey + q)
|
||||||
the debug file is in /var/log/fenrir.log
|
the debug file is in /tmp/fenrir.log
|
||||||
|
if another Fenrir debug instance is already using it, check /tmp/fenrir2.log,
|
||||||
|
/tmp/fenrir3.log, etc.
|
||||||
|
|
||||||
please be as precise as possible to make it easy to solve the problem.
|
please be as precise as possible to make it easy to solve the problem.
|
||||||
|
|||||||
@@ -183,7 +183,8 @@ double_tap_timeout=0.2
|
|||||||
# The default is 0, no logging.
|
# The default is 0, no logging.
|
||||||
debug_level=0
|
debug_level=0
|
||||||
# debugMode sets where the debug output should send to:
|
# debugMode sets where the debug output should send to:
|
||||||
# debugMode=File writes to debug_file (Default:/tmp/fenrir-PID.log)
|
# debugMode=File writes to debug_file (Default:/tmp/fenrir.log)
|
||||||
|
# If the default log is already in use, Fenrir uses /tmp/fenrir2.log, etc.
|
||||||
# debugMode=Print just prints on the screen
|
# debugMode=Print just prints on the screen
|
||||||
debug_mode=File
|
debug_mode=File
|
||||||
debug_file=
|
debug_file=
|
||||||
|
|||||||
@@ -114,7 +114,7 @@ sudo ./fenrir -f -d -p
|
|||||||
|
|
||||||
# Debug output goes to:
|
# Debug output goes to:
|
||||||
# - Console (with -p flag)
|
# - Console (with -p flag)
|
||||||
# - /var/log/fenrir.log
|
# - /tmp/fenrir.log
|
||||||
```
|
```
|
||||||
|
|
||||||
## Creating Commands
|
## Creating Commands
|
||||||
|
|||||||
+4
-2
@@ -50,7 +50,9 @@ Multiple settings can be separated by semicolons.
|
|||||||
|
|
||||||
.TP
|
.TP
|
||||||
.BR \-d ", " \-\-debug
|
.BR \-d ", " \-\-debug
|
||||||
Enable debug mode. Debug information will be logged to /var/log/fenrir.log.
|
Enable debug mode. Debug information will be logged to /tmp/fenrir.log by
|
||||||
|
default. If another Fenrir debug instance is already using it, Fenrir uses
|
||||||
|
/tmp/fenrir2.log, /tmp/fenrir3.log, etc.
|
||||||
|
|
||||||
.TP
|
.TP
|
||||||
.BR \-p ", " \-\-print
|
.BR \-p ", " \-\-print
|
||||||
@@ -476,7 +478,7 @@ User sound themes
|
|||||||
User scripts
|
User scripts
|
||||||
|
|
||||||
.TP
|
.TP
|
||||||
.B /var/log/fenrir.log
|
.B /tmp/fenrir.log
|
||||||
Debug log file
|
Debug log file
|
||||||
|
|
||||||
.TP
|
.TP
|
||||||
|
|||||||
+3
-3
@@ -2276,13 +2276,13 @@ that shows the issue.
|
|||||||
|
|
||||||
==== How-to create a debug file
|
==== How-to create a debug file
|
||||||
|
|
||||||
. Delete old debug stuff +
|
|
||||||
`+sudo rm /var/log/fenrir.log+`
|
|
||||||
. Start fenrir in debug mode +
|
. Start fenrir in debug mode +
|
||||||
`+sudo fenrir -d+`
|
`+sudo fenrir -d+`
|
||||||
. Do your stuff to reproduce the problem
|
. Do your stuff to reproduce the problem
|
||||||
. Stop fenrir (`+fenrirKey + q+`)
|
. Stop fenrir (`+fenrirKey + q+`)
|
||||||
|
|
||||||
the debug file is located in `+/var/log/fenrir.log+`
|
the debug file is located in `+/tmp/fenrir.log+`. If another Fenrir debug
|
||||||
|
instance is already using it, check `+/tmp/fenrir2.log+`,
|
||||||
|
`+/tmp/fenrir3.log+`, etc.
|
||||||
|
|
||||||
Please be as precise as possible to make it easy to solve the problem.
|
Please be as precise as possible to make it easy to solve the problem.
|
||||||
|
|||||||
+1
-1
@@ -428,7 +428,7 @@ For a dedicated PTY/terminal screen reader, see TDSR: https://github.com/tspivey
|
|||||||
### Debug Mode
|
### Debug Mode
|
||||||
```bash
|
```bash
|
||||||
sudo fenrir -f -d
|
sudo fenrir -f -d
|
||||||
# Debug output goes to /var/log/fenrir.log
|
# Debug output goes to /tmp/fenrir.log
|
||||||
```
|
```
|
||||||
|
|
||||||
## Getting Help
|
## Getting Help
|
||||||
|
|||||||
+3
-2
@@ -1315,10 +1315,11 @@ Please report Bugs and feature requests to:
|
|||||||
|
|
||||||
for bugs please provide a [[#Howto create a debug file|debug]] file that shows the issue.
|
for bugs please provide a [[#Howto create a debug file|debug]] file that shows the issue.
|
||||||
==== How-to create a debug file ====
|
==== How-to create a debug file ====
|
||||||
- Delete old debug stuff\\ ''sudo rm /var/log/fenrir.log''
|
|
||||||
- Start fenrir in debug mode\\ ''sudo fenrir -d''
|
- Start fenrir in debug mode\\ ''sudo fenrir -d''
|
||||||
- Do your stuff to reproduce the problem
|
- Do your stuff to reproduce the problem
|
||||||
- Stop fenrir (''fenrirKey + q'')
|
- Stop fenrir (''fenrirKey + q'')
|
||||||
the debug file is located in ''/var/log/fenrir.log''
|
the debug file is located in ''/tmp/fenrir.log''. If another Fenrir debug
|
||||||
|
instance is already using it, check ''/tmp/fenrir2.log'',
|
||||||
|
''/tmp/fenrir3.log'', etc.
|
||||||
|
|
||||||
Please be as precise as possible to make it easy to solve the problem.
|
Please be as precise as possible to make it easy to solve the problem.
|
||||||
|
|||||||
@@ -3,24 +3,22 @@
|
|||||||
|
|
||||||
import os
|
import os
|
||||||
import pathlib
|
import pathlib
|
||||||
|
import fcntl
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
|
||||||
from fenrirscreenreader.core import debug
|
from fenrirscreenreader.core import debug
|
||||||
|
|
||||||
|
|
||||||
class DebugManager:
|
class DebugManager:
|
||||||
|
DEFAULT_LOG_DIR = "/tmp"
|
||||||
|
DEFAULT_LOG_BASENAME = "fenrir"
|
||||||
|
DEFAULT_LOG_EXTENSION = ".log"
|
||||||
|
|
||||||
def __init__(self, file_name=""):
|
def __init__(self, file_name=""):
|
||||||
self._file = None
|
self._file = None
|
||||||
self._fileOpened = False
|
self._fileOpened = False
|
||||||
self._fileName = (
|
|
||||||
"/tmp/fenrir_"
|
|
||||||
+ str(os.getpid())
|
|
||||||
+ "_"
|
|
||||||
+ str(datetime.utcnow().strftime("%Y-%m-%d_%H-%M-%S"))
|
|
||||||
+ ".log"
|
|
||||||
)
|
|
||||||
if file_name != "":
|
|
||||||
self._fileName = file_name
|
self._fileName = file_name
|
||||||
|
self._useDefaultLogName = file_name == ""
|
||||||
|
|
||||||
def initialize(self, environment):
|
def initialize(self, environment):
|
||||||
self.env = environment
|
self.env = environment
|
||||||
@@ -39,6 +37,10 @@ class DebugManager:
|
|||||||
self._fileOpened = False
|
self._fileOpened = False
|
||||||
if file_name != "":
|
if file_name != "":
|
||||||
self._fileName = file_name
|
self._fileName = file_name
|
||||||
|
self._useDefaultLogName = False
|
||||||
|
if self._useDefaultLogName:
|
||||||
|
self._open_default_debug_file()
|
||||||
|
return
|
||||||
if self._fileName != "":
|
if self._fileName != "":
|
||||||
directory = os.path.dirname(self._fileName)
|
directory = os.path.dirname(self._fileName)
|
||||||
if not os.path.exists(directory):
|
if not os.path.exists(directory):
|
||||||
@@ -51,6 +53,43 @@ class DebugManager:
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(e)
|
print(e)
|
||||||
|
|
||||||
|
def _open_default_debug_file(self):
|
||||||
|
pathlib.Path(self.DEFAULT_LOG_DIR).mkdir(parents=True, exist_ok=True)
|
||||||
|
log_number = 1
|
||||||
|
while True:
|
||||||
|
log_file = self._default_log_file_name(log_number)
|
||||||
|
try:
|
||||||
|
fd = os.open(
|
||||||
|
log_file,
|
||||||
|
os.O_CREAT | os.O_RDWR | os.O_NOFOLLOW,
|
||||||
|
0o644,
|
||||||
|
)
|
||||||
|
file_obj = os.fdopen(fd, "a")
|
||||||
|
fcntl.flock(file_obj.fileno(), fcntl.LOCK_EX | fcntl.LOCK_NB)
|
||||||
|
file_obj.seek(0)
|
||||||
|
file_obj.truncate()
|
||||||
|
os.chmod(log_file, 0o644)
|
||||||
|
self._file = file_obj
|
||||||
|
self._fileName = log_file
|
||||||
|
self._fileOpened = True
|
||||||
|
return
|
||||||
|
except BlockingIOError:
|
||||||
|
try:
|
||||||
|
file_obj.close()
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
log_number += 1
|
||||||
|
except OSError as e:
|
||||||
|
print(e)
|
||||||
|
return
|
||||||
|
|
||||||
|
def _default_log_file_name(self, log_number):
|
||||||
|
suffix = "" if log_number == 1 else str(log_number)
|
||||||
|
return os.path.join(
|
||||||
|
self.DEFAULT_LOG_DIR,
|
||||||
|
self.DEFAULT_LOG_BASENAME + suffix + self.DEFAULT_LOG_EXTENSION,
|
||||||
|
)
|
||||||
|
|
||||||
def write_debug_out(
|
def write_debug_out(
|
||||||
self, text, level=debug.DebugLevel.DEACTIVE, on_any_level=False
|
self, text, level=debug.DebugLevel.DEACTIVE, on_any_level=False
|
||||||
):
|
):
|
||||||
@@ -120,3 +159,4 @@ class DebugManager:
|
|||||||
def set_debug_file(self, file_name):
|
def set_debug_file(self, file_name):
|
||||||
self.close_debug_file()
|
self.close_debug_file()
|
||||||
self._fileName = file_name
|
self._fileName = file_name
|
||||||
|
self._useDefaultLogName = file_name == ""
|
||||||
|
|||||||
@@ -0,0 +1,59 @@
|
|||||||
|
from fenrirscreenreader.core.debugManager import DebugManager
|
||||||
|
|
||||||
|
|
||||||
|
def test_default_debug_file_uses_flat_name(tmp_path, monkeypatch):
|
||||||
|
monkeypatch.setattr(DebugManager, "DEFAULT_LOG_DIR", str(tmp_path))
|
||||||
|
manager = DebugManager()
|
||||||
|
try:
|
||||||
|
manager.open_debug_file()
|
||||||
|
|
||||||
|
assert manager.get_debug_file() == str(tmp_path / "fenrir.log")
|
||||||
|
assert (tmp_path / "fenrir.log").exists()
|
||||||
|
finally:
|
||||||
|
manager.close_debug_file()
|
||||||
|
|
||||||
|
|
||||||
|
def test_default_debug_file_uses_next_number_when_locked(
|
||||||
|
tmp_path, monkeypatch
|
||||||
|
):
|
||||||
|
monkeypatch.setattr(DebugManager, "DEFAULT_LOG_DIR", str(tmp_path))
|
||||||
|
first_manager = DebugManager()
|
||||||
|
second_manager = DebugManager()
|
||||||
|
try:
|
||||||
|
first_manager.open_debug_file()
|
||||||
|
second_manager.open_debug_file()
|
||||||
|
|
||||||
|
assert first_manager.get_debug_file() == str(tmp_path / "fenrir.log")
|
||||||
|
assert second_manager.get_debug_file() == str(
|
||||||
|
tmp_path / "fenrir2.log"
|
||||||
|
)
|
||||||
|
assert (tmp_path / "fenrir2.log").exists()
|
||||||
|
finally:
|
||||||
|
second_manager.close_debug_file()
|
||||||
|
first_manager.close_debug_file()
|
||||||
|
|
||||||
|
|
||||||
|
def test_default_debug_file_reuses_unlocked_flat_name(tmp_path, monkeypatch):
|
||||||
|
monkeypatch.setattr(DebugManager, "DEFAULT_LOG_DIR", str(tmp_path))
|
||||||
|
first_manager = DebugManager()
|
||||||
|
second_manager = DebugManager()
|
||||||
|
try:
|
||||||
|
first_manager.open_debug_file()
|
||||||
|
first_manager.close_debug_file()
|
||||||
|
second_manager.open_debug_file()
|
||||||
|
|
||||||
|
assert second_manager.get_debug_file() == str(tmp_path / "fenrir.log")
|
||||||
|
finally:
|
||||||
|
second_manager.close_debug_file()
|
||||||
|
|
||||||
|
|
||||||
|
def test_explicit_debug_file_uses_exact_path(tmp_path):
|
||||||
|
debug_file = tmp_path / "custom.log"
|
||||||
|
manager = DebugManager(str(debug_file))
|
||||||
|
try:
|
||||||
|
manager.open_debug_file()
|
||||||
|
|
||||||
|
assert manager.get_debug_file() == str(debug_file)
|
||||||
|
assert debug_file.exists()
|
||||||
|
finally:
|
||||||
|
manager.close_debug_file()
|
||||||
Reference in New Issue
Block a user