deponian / logalize

Fast and extensible log colorizer Alternative to ccze
MIT License
23 stars 0 forks source link

Weird highlighting behaviour #2

Open dgudim opened 1 week ago

dgudim commented 1 week ago

I copied the default config and changed the colors, but I noticed 2 things

  1. there are still some original colors left even though I changed all of them in the config
  2. some parts are highlighted weirdly

My config:

formats:
  # $remote_addr - $remote_user [$time_local] "$request" $status $body_bytes_sent "$http_referer" "$http_user_agent"
  nginx-combined:
    # $remote_addr
    - regexp: (\d{1,3}(\.\d{1,3}){3} )
      fg: 11
    # -
    - regexp: (- )
      fg: 8
    # $remote_user
    - regexp: ([^ ]+ )
      fg: 5
    # [$time_local]
    - regexp: (\[.+\] )
      fg: 6
    # "$request"
    - regexp: ("[^"]+" )
      fg: 14
    # $status
    - regexp: (\d\d\d )
      fg: 15
      alternatives:
        - regexp: (2\d\d )
          fg: 2
          style: bold
        - regexp: (3\d\d )
          fg: 6
          style: bold
        - regexp: (4\d\d )
          fg: 9
          style: bold
        - regexp: (5\d\d )
          fg: 13
          style: bold
    # $body_bytes_sent
    - regexp: ([\d]+ )
      fg: 8
    # "$http_referer"
    - regexp: ("[^"]+" )
      fg: 6
    # "$http_user_agent"
    - regexp: ("[^"]+")
      fg: 13

patterns:
  string:
    priority: 500
    regexp: ("[^"]+"|'[^']+')
    fg: 2

  number:
    regexp: (\d+)
    fg: 6
    style: bold

  http-status-code:
    regexp: (\d\d\d)
    fg: 15
    alternatives:
      - regexp: (2\d\d)
        fg: 2
      - regexp: (3\d\d)
        fg: 6
      - regexp: (4\d\d)
        fg: 9
      - regexp: (5\d\d)
        fg: 13

  ipv4-address:
    regexp: (\d{1,3}(\.\d{1,3}){3})
    fg: 9
    bg: 11

words:
  success:
    fg: 10
    style: bold
    list:
      - "open"
      - "finish"

  warning:
    fg: 11
    style: bold
    list:
      - "ignore"
      - "miss"
      - "readonly"
      - "reload"
      - "skip"
      - "warn"
      - "restart"

Orig: image

Changed: image

deponian commented 1 week ago

Hi again :)

The config that is provided with the logalize package (the one in /etc/logalize/logalize.yaml) is just an example, not the default one. Logalize has some formats, patterns and words built-in right into the executable file. You can see these builtins here or print them with logalize -b.

You can disable some of the builtins or even all of them with -L, -P, -W or -N flags. See more in logalize -h. For example, if you use -N flag it will turn off all built-in stuff and the only source for colorization info will be your configuration file.

dgudim commented 1 week ago

Ohhh, makes sense. I basically want to change the colors, but don't touch the patters/formats/etc. The only way to do that if I understand correctly is to copy all the builtins and change the colors. Are color themes planned? Or maybe make the defaults use terminal colors? :thinking:

deponian commented 1 week ago

Themes are in the plans, but I can't promise it will be soon :/

Why do you want to use ANSI terminal colors instead of the full RGB TrueColor? Most modern terminals support it. And if you try to use logalize in something like Linux virtual console with only basic 256 colors it will fall back from TrueColor to ANSI automatically.

dgudim commented 1 week ago

The main reason is that if i change the color/color theme in one place, it automatically changes in all of my tools. Absolutely no pressure with color themes, I am just looking for a good log highlighter, I don't want you to implement the feature just because I want it, take your time, just wanted to know the plans :)

deponian commented 1 week ago

We need themes for logalize, that's for sure :) I will leave this issue open until I implement theme support. You can subscribe to it if you want

dgudim commented 1 week ago

Will do! Thanks again!