Much needed: well-highlighted JSON log viewer

前端 未结 7 883
感动是毒
感动是毒 2021-01-30 22:46

Using winston for node.js logging, I get json log files. A log file in this vein is simply a sequence of (newline delimited) json objects. This is great for log querying and tre

7条回答
  •  灰色年华
    2021-01-30 23:22

    Mixing Allen Bargui's and MattDMo's answers, you can change the color of the nested keys/values by simply adding more dicts specifying the depth of the code by adding a meta after the source.json word.

    Locate the theme file by going to Preferences > Browse Packages and then inside the Color Scheme - Default folder. Edit it by adding these lines:

    
        name
        Json Keys - 1 deep
        scope
        source.json meta meta.structure.dictionary.json string.quoted.double.json
        settings
        
            foreground
            #FF0000 
        
    
    
    
        name
        JSON Values - 1 deep
        scope
        source.json meta meta.structure.dictionary.json meta.structure.dictionary.value.json string.quoted.double.json
        settings
        
            foreground
            #00FF00 
        
    
    
    
        name
        Json Keys
        scope
        source.json meta.structure.dictionary.json string.quoted.double.json
        settings
        
            foreground
            #FF0000 
        
    
    
    
        name
        JSON Values
        scope
        source.json meta.structure.dictionary.json meta.structure.dictionary.value.json string.quoted.double.json
        settings
        
            foreground
            #00FF00 
        
    
    

    It's important to add the deeper ones BEFORE the rest, as Sublime will select the first matching occurrence. I guessed adding more meta would work for further depths but it actually didn't... But it did the trick for depth 1 at least.

提交回复
热议问题