Highlight whole line based on keyword found in line

Highlight whole line based on keyword found in line

1
NewbieNewbie
1

    Apr 13, 2009#1

    I'd like to have syntax highlighting on log4j logs. They might look something like this, although the output formatting is very flexible:

    Code: Select all

    2009-04-13 13:49:52,101 FATAL [main/Monitor]: Service will be restarted, socket test result: Timeout: java.net.SocketTimeoutException: Read timed out
    2009-04-13 13:49:52,101  INFO [main/Monitor]: Ending tests.  Tests took 15187 milliseconds.
    2009-04-13 13:49:52,101  INFO [main/Monitor]: Restarting service...
    2009-04-13 13:49:52,101 ERROR [main/Monitor]: org.hyperic.sigar.win32.Win32Exception: The specified service does not exist as an installed service.
    Log4j has 6 built-in logging levels: TRACE, DEBUG, INFO, WARN, ERROR, and FATAL.
    I'd like to have the whole line highlighted based on which of these keywords appears in the line.

    From what I've concluded, the current method UE uses for highlighting isn't designed for this, but I'd love to be wrong.
    I've tried best I can to trick the highlighting parser; using some the keywords as comments, disabling delimiters, using variable strings, faking the markers, etc, but can't come up with a good solution to this problem.
    Any ideas?

    6,681583
    Grand MasterGrand Master
    6,681583

      Apr 14, 2009#2

      I think, there is no chance to get what you want with the UltraEdit syntax highlighting engine.

      What about converting your log files into HTML files with appropriate color settings with a macro. Here is an UE v14.20.1.1008 macro for that conversion. After running this macro you have a copy of your log file with extension HTM which is a valid HTML file and you can view with your browser.

      Code: Select all

      InsertMode
      ColumnModeOff
      HexOff
      PerlReOn
      Top
      Find MatchCase RegExp "^(.*DEBUG.*)$"
      Replace All "<span class="debug">\1</span>"
      Find MatchCase RegExp "^(.*ERROR.*)$"
      Replace All "<span class="error">\1</span>"
      Find MatchCase RegExp "^(.*FATAL.*)$"
      Replace All "<span class="fatal">\1</span>"
      Find MatchCase RegExp "^(.*INFO.*)$"
      Replace All "<span class="info">\1</span>"
      Find MatchCase RegExp "^(.*TRACE.*)$"
      Replace All "<span class="trace">\1</span>"
      Find MatchCase RegExp "^(.*WARN.*)$"
      Replace All "<span class="warn">\1</span>"
      Bottom
      IfColNum 1
      Key BACKSPACE
      EndIf
      "</pre>
      
      </body>
      </html>
      "
      Top
      "<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN""
      "
      "http://www.w3.org/TR/html4/strict.dtd">
      <html>
      <head>
      <title></title>
      <meta http-equiv="content-style-type" content="text/css">
      <meta http-equiv="content-type" content="text/html; charset=iso-8859-1">
      <style type="text/css">
      .debug { color:gray }
      .error { color:maroon }
      .fatal { color:red }
      .info  { color:blue }
      .trace { color:green }
      .warn  { color:navy }
      </style>
      </head>
      <body>
      
      <pre>"
      Clipboard 9
      GotoLine 5 8
      CopyFilePath
      Paste
      ColumnModeOn
      GotoLine 2 1
      "  "
      GotoLine 5 1
      GotoLineSelect 15 1
      ColumnInsert " "
      GotoLine 9 1
      GotoLineSelect 14 1
      ColumnInsert " "
      ColumnModeOff
      Top
      Paste
      StartSelect
      Find Up Select "."
      ".htm"
      StartSelect
      Key HOME
      Cut
      SaveAs "^c"
      ClearClipboard
      Clipboard 0
      Best regards from an UC/UE/UES for Windows user from Austria

      61
      Advanced UserAdvanced User
      61

        Apr 14, 2009#3

        I like this!!! Another great idea!!

        1
        NewbieNewbie
        1

          Nov 24, 2010#4

          Has this ever gotten into the product?

          I have a specific use for this while reading log files.

          I would use "markers" and this would give me the ability to highlight the entire line (foreground=text color, and Background=fill color for the line)

          Another feature would be to GREP (search a folder for a string of text in any of the files within the folder, .log, .txt)

          6,681583
          Grand MasterGrand Master
          6,681583

            Nov 25, 2010#5

            For viewing log files there are the advanced find commands Hide Lines and Show Lines. Just press Ctrl+F to open the find dialog and click on button Advanced to see the advanced find options and commands. With Hide Lines and Show Lines you can filter the log file to what you want to see and hide the other lines. You can also use the advanced find option List Lines Containing String if you want to see all lines containing a string in a separate window, navigate quickly through these lines or copy them to clipboard for pasting them into a new file.

            Further there is the command Search - Find in Files, the equivalent to GREP.

            But to answer your first question, it is still not possible in UE v16.20.0.1011 to use regular expressions for syntax highlighting except for finding strings for the function list view. So highlighting an entire line can be done only with line comment highlighting if the line comment starting string is at start of a line, for example a marker character/string which you add to a log file using a regular expression replace all which is specified in the syntax highlighting wordfile as line comment starting string.

            If you want to mark just some lines, use the bookmark feature - see Search - Bookmarks. With the configuration setting Highlight entire line at Advanced - Configuration - Editor - Bookmarks you can see the bookmarked lines now completely with the bookmark background color defined at View - Set Color. And there is View - Views/Lists - Bookmark Viewer.
            Best regards from an UC/UE/UES for Windows user from Austria