agusmakmun / agusmakmun/django-log-viewer

Need help in using regex with LOG_VIEWER_PATTERNS

Aperta
#29 2 commenti 0 reazioni 0 assegnatari Vedi su GitHub
Lingua principale
JavaScript
Stelle
85
Fork
32
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

My `LOG_VIEWER_PATTERNS` setting
```
LOG_VIEWER_PATTERNS = ['\d\d\d\d\d\d\d\dT\d\d\d\d\d\dZ#USR=\d#AU=\d#IU=\d#DVC=\d#AD=\d#PD=\d']
```

How my log looks like on django-log-viewer with this setting (pattern not working as I would hope):
```
20220113T142500Z#USR=1#AU=1#IU=0#DVC=0#AD=0#PD=020220113T213000Z#USR=1#AU=1#IU=0#DVC=0#AD=0#PD=1
```

How the log is formatted:
```py
'fticks':{
'format':'{asctime}{message}',
'datefmt':'%Y%m%dT%H%M%SZ',
'style':'{',
},
```
```py
log_message='#USR={}#AU={}#IU={}#DVC={}#AD={}#PD={}'.format(ldap_users,active_users,inactive_users,devices,approved_devices,pending_devices)
```

An external test of the same regex pattern I've used with django-log-viewer successfully parses this:
```py
# regex-test.py
import re

stringLog='20220113T142500Z#USR=1#AU=1#IU=0#DVC=0#AD=0#PD=020220113T213000Z#USR=1#AU=1#IU=0#DVC=0#AD=0#PD=1'

pattern=re.compile(r'\d\d\d\d\d\d\d\dT\d\d\d\d\d\dZ#USR=\d#AU=\d#IU=\d#DVC=\d#AD=\d#PD=\d')
matches=pattern.finditer(stringLog)

for match in matches:
print(match)
```
```shell
$ python regex-test.py

```

I know I have done something wrong here and would appreciate someone pointing out how I can get this log of mine to split into newlines instead of getting tangled into a single entry in the log viewer. Thanks!

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.