highlighting log files
-
UDL has always confused me but luckily I’ve managed to avoid it until now.
I am running and old NPP 6.9.2 (due to problem getting python running in V7) which appears to run UDL 2.1.0.12
Basically what I want is when I load a log file I want it to have a black background and generally all the lines in white, but most importantly have any line which contains the string “!!!” show as red, and anything which contains the string “???” show as yellow, basically highlight complete lines based on the appearance or no-appearance of some string…
Using UDL I can get the !!! and ??? highlighted but not the whole line they appear in.
A long time ago I tried using python to do this instead, but, it wasn’t as easy as I thought it should be with all the scintilla commands and mass of documentation to wade through.
Has anyone got a starter or an example for me and is it a UDL or Pythn kind of deal?
ian
-
@gbilai1 said:
Using UDL I can get the !!! and ??? highlighted but not the whole line they appear in.
That’s not the goal of UDL. It’s for syntax highlighting, and syntaxes usually have keywords, comments, and delimiters. Using comments and/or delimiters, you can come closer to what you described you got, but not exactly what you want.
Comments – specifically, the comment-line-style – could be used for highlighting every from the !!! or ??? marker to the end-of-line. And if you use the
((EOL))
marker (which indicates the end of the line) for the “End”, you could use the multi-line “Comment Style” for the alternate marker.Or you could use two different Delimiters, for example setting “Delimiter 1” to start=
!!!
and end=((EOL))
, and “Delimiter 2” to start=???
and end=((EOL))
to accomplish similar marker-to-end-of-line highlighting.However, I know of no way in UDL to highlight everything from the beginning to the end of the line to the end of the line with the same styling, assuming it contains that .
You could do it in PythonScript, but you’d have to mess around with the scintilla commands. Then again, if someone were to write it for you, they would have to mess around with all the scintilla commands for you.
If you’re just trying to quickly mark things, you could use the Search > Mark… dialog and maybe use the standard option for
(?-s)^.*!!!.*$
and maybe use theBookmark Line
checkbox when doing(?-s)^.*\?\?\?.*$
. You could possibly even record a macro which does those two separate events (though I’m not remembering if all those settings apply correctly when recording macros… I think so, but you’d have to give it a try). -
if you have pythonscript plugin installed, then checkout plugins->pythonscript->scripts->samples.
There is a script called LogfileLexer which may be used. -
That’s one perfect answer. Thank you sir.
I’ve used NPP for a long time and am surprised this isn’t more in demand as a built in as I’d have preferred some log colorization based on user keywords than developing the tailing of log files. Even though it may hack off Peter, and yes, log files aren’t a language with a defined syntax, UDL has the essential logic to mark up log files or report files to highlight key lines. Vim allows you to do it, even though I had to write the log “syntax” rules. Just saying ;-)
BTW: It isn’t in my pythonscript samples menu - I had to search in Google to find the code on github (and I assume it is the same).
-
I’ve used NPP for a long time and am surprised this isn’t more in demand as a built
As much as I understand that this would be advantageous for you, if this functionality would be available from buitlin, I am, personally, against it, to integrate everything possible in Npp. This would question the plugin system itself and the program would become more and more complex and error-prone for all users, even if you might only use a few additional functions.
From my point of view, Npp is already stuffed with far too much functionality. I would prefer a Npp that concentrates only on the core tasks, i.e. UI, Scintilla and Boost::Regex.
As I said, my opinion, I am well aware that most users probably disagree.BTW: It isn’t in my pythonscript samples menu - I had to search in Google to find the code on github (and I assume it is the same).
Could it be that you are not using one of the later versions? Currently, 1.4 is the latest.
-
I (mildly) agree since npp is a marvellous tool and as you say does risk being too feature packed with things people don’t use or are of limited value and are just clutter or bloat for regular users.
Obviously someone created a sample exactly like the requirement I was after so the requirement isn’t too bespoke or unheard of, and I have been known to switch to use gVim to quickly scan through logs so see them colour coded and make issues just “jump out at me” quickly and easily.
Peter’s reply of using find and mark using regex ala “.(!!!|???).” is something I was aware of and goes some way towards a non-python solution but I’ve used that in the past and yet still asked the question as it seems too clunky and I have other strings I need to search for and mark.
I am down-level on Python - 1.0.8.0! but last time I tried upgrade npp itself to V7 the whole thing went to pot running any python script (a built-in or non-python plug-in (possibly) wouldn’t suffer). I have a few python scripts so am just concerned over upgrade paths but don’t like being down level so I may try again soon using advice on the forum as many people had issues with python and some versions of npp V7 which, hopefully, are resolved ;-(
I even had problems going back from V7 to V6, but, I can’t remember what that issue was, but, once bitten twice shy as we say.ian
-
@gbilai1 said:
I am down-level on Python - 1.0.8.0! but last time I tried upgrade npp itself to V7 the whole thing went to pot running any python script (a built-in or non-python plug-in (possibly) wouldn’t suffer). I have a few python scripts so am just concerned over upgrade paths but don’t like being down level so I may try again soon using advice on the forum as many people had issues with python and some versions of npp V7 which, hopefully, are resolved ;-(
I even had problems going back from V7 to V6, but, I can’t remember what that issue was, but, once bitten twice shy as we say.-
It’s actually possible to install PythonScript 1.4 on older Notepad++ (like v7.5.9) by just downloading the most recent PythonScript zip, and unzipping the various files on top of the existing ones in your Notepad++ plugins installation.
-
To run python in the newest Notepad++ (v7.7.1), follow this Guide. It works, too.
You also said:
Obviously someone created a sample exactly like the requirement I was after so the requirement isn’t too bespoke or unheard of,
But it’s not a universal or even majority feature-need. And it’s handled by a pythonscript, so the developers will likely see no reason to implement it natively.
-
-
unfortunately, the pythonscript plugin isn’t up-to-date anymore.
As you’ve already figured out, the plugin, for x64, isn’t fully functional since npp >=7.7
The reason is that with 7.7 npp updated its scintilla control which itself introduced
a change in the notification structure and therefore broke backward compatibility. :-(
In addition, there doesn’t seem to be any progress in moving to python3.I’m currently working on a python3 plugin with a slightly different approach.
The plugin itself provides just the UI interface as well as the initial python initialization
but the wrapper code (for scintilla and notepad++) are python modules.
I hope to make the first alpha version available at github mid to end next week.
I’m trying to be backward compatible with the existing pythonscript plugin, means one should have minimum or better no work to do to make it run with my version of it.
The only headache problem I have is how to implement the boost::regex thing. -
@Ekopalypse said:
unfortunately, the pythonscript plugin isn’t up-to-date anymore.
As you’ve already figured out, the plugin, for x64, isn’t fully functional since npp >=7.7
The reason is that with 7.7 npp updated its scintilla control which itself introduced
a change in the notification structure and therefore broke backward compatibility. :-(The only thing I’ve seen not work is notifications / callbacks. Other than that, PythonScript works just fine with NPP v7.7.1, for everything I’ve tried. That said, it is likely that LogfileLexer relies on notifications/callbacks, so the example script might not work with v7.7.1.
So then my advice of how to update PythonScript in an older Notepad++ is still valid.
-
yes, all the lexer stuff and automatic change things stuff depends on notifications.
But you are right, PS can still be used without those limitations and < 7.7. it should be full functioning. -
@Ekopalypse maybe should have been more specific. Pythonscript is only broken with 64-bit version of Notepad++ >= 7.7. For 32-bit it works just fine in all aspects.
-
As you’ve already figured out, the plugin, for x64, isn’t fully functional since npp >=7.7
you did this on purpose so that I don’t feel dump, didn’t you? :-D
-
the plugin, for x64, isn’t fully functional since npp >=7.7
OK, you did say it. Sorry; there’s a lot going on in this thread! Including your announcement! :)
The only headache problem I have is how to implement the boost::regex thing.
Is it a headache? Can you just do it how Pythonscript does it? Or is that what keeps P.S. tied to Python 2.7? I really don’t know…
-
No, unfortunately not that easy.
I’m using cffi to build the plugin and I haven’t figured out how to add boost::regex to it and make it compile.
Currently I’m investigating how to make a python extension module using cython
or cppyy or maybe nuitka (I’m unsure, it seems to be an exe builder).
I’ve read that cython can handle boost templates very well so … -
This post is deleted!