@@ -47,22 +47,12 @@ func main() {
4747 out .WriteString ("|Type|Java Method|Date|\n |------|------|------|\n " )
4848
4949 for scanner .Scan () {
50- example := scanner .Text ()
51- // Non-JSON logs mean we split by tabs
52- split := strings .Split (example , "\t " )
53-
54- // Last element is the JSON "body" of the log line
55- example = split [len (split )- 1 ]
56- example = strings .Replace (example , "***" , "{" , 1 )
57- example = strings .Replace (example , "***" , "}" , 1 )
58-
59- res := DeprecationResponse {}
60- err = json .Unmarshal ([]byte (example ), & res )
50+ line , err := parseLogLine (scanner .Text ())
6151 if err != nil {
62- log .Warn ("failed to unmarshal JSON" , zap .Error (err ))
52+ log .Warn (err .Error ())
6353 continue
6454 }
65- responses = append (responses , res )
55+ responses = append (responses , line )
6656 }
6757
6858 // Quit out if there is no deprecations logged
@@ -91,3 +81,19 @@ func main() {
9181 // Print to stdout
9282 fmt .Println (out .String ())
9383}
84+
85+ func parseLogLine (line string ) (DeprecationResponse , error ) {
86+ // Non-JSON logs mean we split by tabs
87+ split := strings .Split (line , "\t " )
88+ fmt .Println (split )
89+
90+ // Last element is the JSON "body" of the log line
91+ line = split [len (split )- 1 ]
92+ line = strings .Replace (line , "***" , "{" , 1 )
93+ line = strings .Replace (line , "***" , "}" , 1 )
94+
95+ res := DeprecationResponse {}
96+ err := json .Unmarshal ([]byte (line ), & res )
97+
98+ return res , err
99+ }
0 commit comments