Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

syslogs #1605

Closed
gmarsano opened this issue Apr 4, 2021 · 10 comments · Fixed by #1606
Closed

syslogs #1605

gmarsano opened this issue Apr 4, 2021 · 10 comments · Fixed by #1606

Comments

@gmarsano
Copy link

gmarsano commented Apr 4, 2021

If there's one thing I really need bat for, it's to query logs, quickly. But it doesn't automatically recognize the syslog syntax and if I enter it manually (-m=syslog=log) it's pretty poor.

I think it is something that by default should be well polished in a tool of this kind.

@keith-hall
Copy link
Collaborator

Thanks for the feedback. Can you share a specific example of a syslog which is highlighted suboptimally please and detail your expectations? :)
It may be that we need to improve the syslog syntax definition we use. Possibly relevant: #463

@gmarsano
Copy link
Author

gmarsano commented Apr 4, 2021

For example:
I got this from bat -m=syslog:log /var/log/syslog:

Captura de pantalla de 2021-04-04 12-10-42

And this from vim PaperColor theme colorscheme:

Captura de pantalla de 2021-04-04 12-10-10

As you can see, it helps to recognize numerical values, dates and highlights failures, errors, returns, etc. I think this particular syntax highlighting is a bit excessive, but it still helps a lot to give a quick look at the log.

It would be nice to have something similar, even better, not so blinding, in bat.

@keith-hall
Copy link
Collaborator

keith-hall commented Apr 4, 2021

After I quick look, I completely agree that the Syslog highlighting from bat was terrible 😅
I created a PR, and it now looks a bit more like this:
image

Suggestions for improvements welcome. (IPv6 addresses look a little weird atm, for example.)

@gmarsano
Copy link
Author

gmarsano commented Apr 5, 2021

That looks better. And what about the failures and errors?

@keith-hall
Copy link
Collaborator

I have updated the PR so that it would highlight errors and failures the same way as invalid syntax in programming languages:
image
I had the idea that highlighting just the word error or failed/failure etc. is cleaner than the full line. Do you agree?

@gmarsano
Copy link
Author

gmarsano commented Apr 5, 2021

Good job! For me it's enough. Now you can take a quick look at the log, easily. Improving the default style could be the subject of another issue, if there was someone more creative or an experienced sys admin who could suggest something more objective.

I just want to remind you that for some reason it doesn't recognize the log syntax by default when I run it on for example / var / log / syslog. If there is a reason for that, it is not a problem to make an alias or something like that, but I think it is a typical log file and maybe it should recognize it by default.

@keith-hall
Copy link
Collaborator

keith-hall commented Apr 5, 2021

I had noticed that previously, the syntax definition was being applied automatically for files called log or with a .log extension, so my PR addresses that to make it apply for files with a .syslog extension (if such a thing is used) or called exactly syslog, as it specifically covers only syslog format files. This means log files will likely not be highlighted by default any more after this change. Probably its worth falling back to trying to recognise various date formats and stuff automatically so this syntax definition can still be used for "normal" log files as well. I'll investigate that when I get some spare time.

Edit: related: #1346 (comment)

@keith-hall
Copy link
Collaborator

I have now pushed up a commit to that PR which enables highlighting of non-syslog log files :)

@gmarsano
Copy link
Author

Hi again. The highlighting for words error, fail/failed/failure (ci) is not working.

@keith-hall
Copy link
Collaborator

Hi again. The highlighting for words error, fail/failed/failure (ci) is not working.

which color scheme / theme are you using? as I mentioned in the PR, color schemes may need patching

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants