Skip to content

Instantly share code, notes, and snippets.

@stav
Created August 13, 2015 19:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stav/8907666333d4e1f73e61 to your computer and use it in GitHub Desktop.
Save stav/8907666333d4e1f73e61 to your computer and use it in GitHub Desktop.
Syntax Definition file for Scrapy log files
# [PackageDev] target_format: plist, ext: tmLanguage
---
name: Scrapy Log
scopeName: source.slog
fileTypes: [slog]
uuid: 030ae93f-5fcf-4bbd-8caa-81fcdcf77ec3
patterns:
- comment: date-time [logger] level
- comment: (Scrapy 1.1.0dev1)
name: support.constant
match: \d{4}-\d{2}-\d{2}\s\d{2}:\d{2}:\d{2} \[([^\]]+)\] ([A-Z]+):\s
captures:
'1': {name: entity.other.attribute-name}
'2': {name: entity.name.tag}
- comment: date-time level [logger]
- comment: (Scrapy 1.0.1.post1+g5b8c9e5)
name: support.constant
match: \d{4}-\d{2}-\d{2}\s\d{2}:\d{2}:\d{2} ([A-Z]+) \[([^\]]+)\]
captures:
'1': {name: entity.name.tag}
'2': {name: entity.other.attribute-name}
- comment: Request
name: constant.other
match: <([A-Z]+)\s([^]]+?)>
captures:
'1': {name: variable.parameter}
'2': {name: string}
- comment: Response
name: constant.other
match: <([\d]+)\s([^]]+?)>
captures:
'1': {name: variable.parameter}
'2': {name: entity.name.class}
...
@stav
Copy link
Author

stav commented Aug 13, 2015

Save YAML file to Sublime User directory, e.g.:

/home/stav/.config/sublime-text-3/Packages/User/ScrapyLog.YAML-tmLanguage

Then build: with Tools > Build System set to "Automatic", use Tools > Build (Ctrl-B)

Save Scrapy log output to a file with an slog extension, for example:

99999_4_18.slog

Then open in Sublime Text and it will be color coded according to your color_scheme.

scrapylog

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment