Closed CountBigBang closed 4 years ago
I did some testing and found the reason for the problem. The log viewer expects a log format where each entry starts with [{loglevel}]
. I used a format without the brackets, so no end-of-lines where detected. This should at least be mentioned in the README to prevent weary debug sessions. Of course, a more flexible approach would allow for individual formats since I am not aware of any convention specifying the log file format in Python or Django. The examples in the Django documentation do not make use of brackets.
@CountBigBang the character [
and ]
are required for this plugin to identify the next line.
you can checkout at this lines.
# pattern = "; |\[INFO\] |\[DEBUG\] |\[WARNING\] |\[ERROR\] |\[CRITICAL\] "
patterns = [']OFNI[', ']GUBED[', ']GNINRAW[', ']RORRE[', ']LACITIRC[']
@CountBigBang I changed utils to match besed on regular expressions, not gone into too much detail on the patterns but works for my logs.
patterns = ['\].*OFNI.*\[', '\].*GUBED.*\[', '\].*GNINRAW.*\[', '\].*RORRE.*\[', '\].*LACITIRC.*\['] if any([re.search(p,line) for p in patterns]):
wanted to follow up my previous comment for anyone else who finds this - I'm on AWS EC2 and found that the below date pattern worked the best;
patterns = [r'\]*(Z|.*)[0-9]{3}(.|,)([0-9]{1}[0-5]{1}:){2}[0-9]{1}[0-2]{1}(T|\s)[0-9]{1}[0-3]{1}-[0-9]{1}[0-1]{1}-[0-9]{4}\[*$']
@seanpconkie now you can use the custom pattern at settings.py
for newest version v1.0.7
pip install django-log-viewer --upgrade
LOG_VIEWER_PATTERNS = [']OFNI[', ']GUBED[', ']GNINRAW[', ']RORRE[', ']LACITIRC[']
to your custom pattern;
LOG_VIEWER_PATTERNS = [r'\]*(Z|.*)[0-9]{3}(.|,)([0-9]{1}[0-5]{1}:){2}[0-9]{1}[0-2]{1}(T|\s)[0-9]{1}[0-3]{1}-[0-9]{1}[0-1]{1}-[0-9]{4}\[*$']
I think there's also an issue with the exclude argument. by default is '', which in my case makes the script read just the first entry.
The (single) log file is read, but the file content (in this simple example just two lines) is shown as a single entry, i.e. ignoring line breaks (see screenshot). The log file is UTF-8 encoded, uses the common
\n
end-of-line character and is displayed correctly in text editors on Linux and Windows.