fluent-plugin-text_to_json 0.1.55 → 0.1.56
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
 - data/lib/fluent/plugin/formatter_text_to_json.rb +2 -4
 - metadata +1 -1
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA1:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: 882de2dbd43f38c83e0ab39e63184491d01ea6fa
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: 2a02dab2c2f232518a28deeee6079839901fb873
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: 595a568e6b954d37ec4a1ef28068f30dc18c86b756fc944ca88dcffea2e89cb685d12e2a6c591dd401a949ae297f71679f4453d3446e4d7b80efa34e6d77b2b6
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: 187d0f97791c8f3a29bfc355f83f1ed5ab767bf19b671f6190e8aaf64eff5a477f89608fbc2c37252cb64afd2e0232cd94bb8abe771d40efe8688d9985b7a884
         
     | 
| 
         @@ -1,18 +1,17 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            require 'fluent/formatter'
         
     | 
| 
      
 2 
     | 
    
         
            +
            require 'json'
         
     | 
| 
       2 
3 
     | 
    
         | 
| 
       3 
4 
     | 
    
         | 
| 
       4 
5 
     | 
    
         
             
            module Fluent
         
     | 
| 
       5 
6 
     | 
    
         
             
              module TextFormatter
         
     | 
| 
       6 
7 
     | 
    
         
             
                 class TextToJsonFormatter < Formatter
         
     | 
| 
       7 
8 
     | 
    
         
             
                    Fluent::Plugin.register_formatter('text_to_json', self)
         
     | 
| 
       8 
     | 
    
         
            -
            	helpers :formatter
         
     | 
| 
       9 
9 
     | 
    
         
             
            	config_param :json_field, :string, :default => "sdr,factor,1,2,3,4,5,6,7,8,9,10,11,12,13"
         
     | 
| 
       10 
10 
     | 
    
         
             
            	config_param :field_splitter, :string, :default => "A000"	
         
     | 
| 
       11 
11 
     | 
    
         | 
| 
       12 
12 
     | 
    
         
             
            	def configure(conf)
         
     | 
| 
       13 
13 
     | 
    
         
             
            	  super
         
     | 
| 
       14 
14 
     | 
    
         
             
            	  @fields = @json_field.split(",").map{|field| "\"" + field + "\""}
         
     | 
| 
       15 
     | 
    
         
            -
            	  @formatter = formatter_create(type: 'json')
         
     | 
| 
       16 
15 
     | 
    
         
             
            	end
         
     | 
| 
       17 
16 
     | 
    
         | 
| 
       18 
17 
     | 
    
         
             
            	def format(tag, time, record)
         
     | 
| 
         @@ -51,8 +50,7 @@ module Fluent 
     | 
|
| 
       51 
50 
     | 
    
         
             
            	  tmp_field[1] = head.zip(new_tail).map{|field,value| field + ":" + value }.join(",") 
         
     | 
| 
       52 
51 
     | 
    
         | 
| 
       53 
52 
     | 
    
         
             
            	  out_string = "{#{@fields[0]}:{#{tmp_field[0]}},#{@fields[1]}:{#{tmp_field[1]}}}"
         
     | 
| 
       54 
     | 
    
         
            -
            	   
     | 
| 
       55 
     | 
    
         
            -
            	  
         
     | 
| 
      
 53 
     | 
    
         
            +
            	  JSON.parse(out_string)
         
     | 
| 
       56 
54 
     | 
    
         | 
| 
       57 
55 
     | 
    
         
             
            	end
         
     | 
| 
       58 
56 
     | 
    
         
             
                end
         
     |