coteditor / CotEditor

Lightweight Plain-Text Editor for macOS
https://coteditor.com
Other
6.46k stars 431 forks source link

Highlighting of additional log files #1466

Closed asins closed 5 months ago

asins commented 1 year ago

Is your feature request related to a problem? Please describe. The editor lacks syntax highlighting for .log files.

Describe the solution you'd like I would like to incorporate highlighting for certain content such as dates, times, property names and values in JSON formatted data, syntax errors, and character highlighting for log levels such as INFO/WARNING/ERROR/DEBUG.

Describe alternatives you've considered None

Additional context image

Document Content Log.yml Document Content:

attributes:
- beginString: (?<= )\d{2}:\d{2}:\d{2}\.\d{3}(?= )
  regularExpression: true
characters: []
commands:
- beginString: System.err:[^\n]+\n
  regularExpression: true
commentDelimiters: {}
comments: []
completions: []
extensions: []
filenames: []
interpreters: []
keywords:
- beginString: ^(?:\d{2}|\d{4}-)?\d{2}-\d{2}
  description: date
  endString: ' '
  ignoreCase: false
  regularExpression: true
metadata:
  author: Asins
  lastModified: '2023-04-01'
  version: '1.0'
numbers: []
outlineMenu: []
strings: []
types:
- beginString: (?<= )(?:D|DEBUG|Debug)(?= )
  regularExpression: true
- beginString: (?<= )(?:E|ERROR|Error|Err)(?= )
  description: 日志级别
  regularExpression: true
- beginString: (?<= )(?:I|INFO|Info)(?= )
  regularExpression: true
- beginString: (?<= )(?:W|WARN|Warn|WARNING|Warning)(?= )
  regularExpression: true
- beginString: \[(?:WARN|INFO|ERROR)(?::[^\]]+)?\]
  ignoreCase: false
  regularExpression: true
values: []
variables:
- beginString: '"[\w\d-]+"(?=:\s*")'
  description: JSON属性名
  ignoreCase: true
  regularExpression: true
- beginString: (?<=":)".*?(?<!\\)"(?=[},])
  description: JSON属性值为字符串
  regularExpression: true
- beginString: (?<=":)\d+(?=[},])
  description: JSON属性值为数字
  regularExpression: true
1024jp commented 1 year ago

Thank you for the feedback and PR. However, I suppose the extension .log is not for a specific file format but can be used for multiple types of log-like text file. Therefore, it might not be relevant to bundle it into CotEditor itself. It would be better to share it separately for the users who need this format.

1024jp commented 5 months ago

Because of the reason I mentioned at