Lexer properties: Log Files

Post Reply
ertank
Posts: 61
Joined: 06.06.2021 21:56

Lexer properties: Log Files

Post by ertank »

Hello,

I am using CudaText version 1.134.0.2 win64.

I wanted to change ISO8601 formatted date time text to be displayed in yellow color as whole. Currently only part of it is in yellow color as can be seen in attached picture.

I could not open settings for "Log files ^" lexer. I could not find it in lexer library. I could not open lexer styles mapping.

I mean I click mentioned menu options, but nothing comes up. No config file opens. Only lexer library display a dialog and others simply does nothing.

Is there any way I play with coloring options of "Log files ^" lexer?

Thanks & Regards,
Ertan
Attachments
image_2021-06-20_002340.png
image_2021-06-20_002340.png (1.94 KiB) Viewed 2276 times
uvviewsoft
Posts: 392
Joined: 01.12.2020 13:46

Post by uvviewsoft »

Lexer is 'lite' so it is not in the LexerLibrary dialog. the file is here-- /home/user/.config/cudatext/data/lexliblite/Log files.cuda-litelexer
If you know the RegEx, you may try to adjust it.
ertank
Posts: 61
Joined: 06.06.2021 21:56

Post by ertank »

Below worked fine for me. It would be nice if it can be added as default

Code: Select all

    "number": {
      "regex": "\\b((\\d+[-/\\.\\:\\\\\\ \\T])+\\d+)\\b",
      "style": "Id1"
    }
Thanks.
uvviewsoft
Posts: 392
Joined: 01.12.2020 13:46

Post by uvviewsoft »

applied that patch. thanks.
ertank
Posts: 61
Joined: 06.06.2021 21:56

Post by ertank »

Thank you.
ertank
Posts: 61
Joined: 06.06.2021 21:56

Post by ertank »

I just wanted to add alternative coloring in "Log files.cuda-litelexer" This is something else than what already exists.

Json parsed OK when CudaText is loading. But, new coloring is not applied. My addition to that lexer file is as following

Code: Select all

"warning2": {
      "regex": "^.*(TEST|ALİ|VELİ).*$",
      "style": "LightBG4"
    }
There are some Turkish national characters. I escaped them thinking UTF8 JSON string is not supported and still not working. Even, TEST is not working.

Do I need to modify some other file(s) in order to have "warning2" to work with this lexer?

Thanks & Regards,
Ertan
uvviewsoft
Posts: 392
Joined: 01.12.2020 13:46

Post by uvviewsoft »

Adding that lines is working, here is my file 'Log files.cuda-litelexer',
I placed your lines in the middle.

Code: Select all

{
  "about": "Converted from Matthias030's lexer by Alexey Torgashin",
  "files": "*.log",
  "case_sens": false,
  "consider_spaces": true,
  "rules": {
    "success": {
      "regex": "^.*((?<!no )success|(?<!nicht )erfolgreich|(no|without( any)?) error|fehlerfrei|(ohne |kein(e)? )fehler|(?<!not )succeed|mit erfolg).*$",
      "style": "LightBG3"
    },
    "error": {
      "regex": "^.*(error|exception|fail|fatal|crash|(?<!be)fehl(geschlagen)?(er)?|(ohne|kein|nicht) erfolg|violat).*$",
      "style": "LightBG1"
    },
    "warning": {
      "regex": "^.*(warn|critical|kritisch|conflict|konflikt|ung(ü|ue)ltig|invalid|(nicht |un)zul(ä|ae)ssig|not ready|nicht bereit|not found|nicht gefunden|no success|not succeed|veraltet|out of date).*$",
      "style": "LightBG2"
    },
    "warning2": {
      "regex": "^.*(TEST|ALİ|VELİ).*$",
      "style": "LightBG4"
    },
    "type": {
      "regex": "\\(.*?\\)|\\[.*?\\]|\\{.*?\\}",
      "style": "Id2"
    },
    "id": {
      "regex": "[a-z_]\\w*",
      "style": "Id"
    },
    "number": {
      "regex": "\\b((\\d+[-/\\.:T])*\\d+)\\b",
      "style": "Id1"
    }
  }
}
lines with 'TEST' word are hilighted in blue.
ertank
Posts: 61
Joined: 06.06.2021 21:56

Post by ertank »

Adding warning2 just below warning works.
Adding it to the last does not work.

Code: Select all

{
  "about": "Converted from Matthias030's lexer by Alexey Torgashin",
  "files": "*.log",
  "case_sens": false,
  "consider_spaces": true,
  "rules": {
    "success": {
      "regex": "^.*((?<!no )success|(?<!nicht )erfolgreich|(no|without( any)?) error|fehlerfrei|(ohne |kein(e)? )fehler|(?<!not )succeed|mit erfolg).*$",
      "style": "LightBG3"
    },
    "error": {
      "regex": "^.*(error|exception|fail|fatal|crash|(?<!be)fehl(geschlagen)?(er)?|(ohne|kein|nicht) erfolg|violat).*$",
      "style": "LightBG1"
    },
    "warning": {
      "regex": "^.*(warn|critical|kritisch|conflict|konflikt|ung(ü|ue)ltig|invalid|(nicht |un)zul(ä|ae)ssig|not ready|nicht bereit|not found|nicht gefunden|no success|not succeed|veraltet|out of date).*$",
      "style": "LightBG2"
    },
    "type": {
      "regex": "\\(.*?\\)|\\[.*?\\]|\\{.*?\\}",
      "style": "Id2"
    },
    "id": {
      "regex": "[a-z_]\\w*",
      "style": "Id"
    },
    "number": {
      "regex": "\\b((\\d+[-/\\.:T])*\\d+)\\b",
      "style": "Id1"
    },
    "warning2": {
      "regex": "^.*(TEST|ALİ|VELİ).*$",
      "style": "LightBG4"
    }
  }
}
This config does not highlight TEST lines for me.
uvviewsoft
Posts: 392
Joined: 01.12.2020 13:46

Post by uvviewsoft »

this is because order of rules matters. Rule above 'warning2' finds 'TEST' before it.
ertank
Posts: 61
Joined: 06.06.2021 21:56

Post by ertank »

It is clear now that rules works on "first match" logic.
Thanks for the explanation.
Post Reply