@@ -114,7 +114,7 @@ func ExampleGetDefaultConfig() {
114114 // "$[\"@timestamp\"]"
115115 // ],
116116 // "width": 30,
117- // "time_format ": "2006-01-02T15:04:05Z07:00"
117+ // "timeFormat ": "2006-01-02T15:04:05Z07:00"
118118 // },
119119 // {
120120 // "title": "Level",
@@ -138,7 +138,7 @@ func ExampleGetDefaultConfig() {
138138 // "width": 0
139139 // }
140140 // ],
141- // "time_layouts ": [
141+ // "timeLayouts ": [
142142 // "01/02 03:04:05PM '06 -0700",
143143 // "Mon Jan _2 15:04:05 2006",
144144 // "Mon Jan _2 15:04:05 MST 2006",
@@ -157,6 +157,7 @@ func ExampleGetDefaultConfig() {
157157 // "2006-01-02 15:04:05",
158158 // "2006-01-02"
159159 // ],
160+ // "isReverseDefault": true,
160161 // "customLevelMapping": {
161162 // "10": "trace",
162163 // "20": "debug",
@@ -395,3 +396,42 @@ func TestByteSizeParseFailed(t *testing.T) {
395396 require .Error (t , err )
396397 })
397398}
399+
400+ func TestReadTimeLayoutsDeprecated (t * testing.T ) {
401+ t .Parallel ()
402+
403+ cfg := config .GetDefaultConfig ()
404+ cfg .TimeLayoutsDeprecated = []string {time .Layout }
405+ cfg .TimeLayouts = nil
406+
407+ configJSON := tests .RequireEncodeJSON (t , cfg )
408+ fileFirst := tests .RequireCreateFile (t , configJSON )
409+
410+ actual , err := config .Read (fileFirst )
411+ if assert .NoError (t , err ) {
412+ assert .ElementsMatch (t , actual .TimeLayouts , cfg .TimeLayoutsDeprecated )
413+ }
414+ }
415+
416+ func TestReadTimeFormatDeprecated (t * testing.T ) {
417+ t .Parallel ()
418+
419+ timeFormat := time .Layout
420+
421+ cfg := config .GetDefaultConfig ()
422+ cfg .Fields = []config.Field {{
423+ Title : "Time" ,
424+ Kind : config .FieldKindNumericTime ,
425+ References : []string {"$.timestamp" , "$.time" , "$.t" , "$.ts" , "$[\" @timestamp\" ]" },
426+ Width : 30 ,
427+ TimeFormatDeprecated : & timeFormat ,
428+ }}
429+
430+ configJSON := tests .RequireEncodeJSON (t , cfg )
431+ fileFirst := tests .RequireCreateFile (t , configJSON )
432+
433+ actual , err := config .Read (fileFirst )
434+ if assert .NoError (t , err ) {
435+ assert .Equal (t , timeFormat , * actual .Fields [0 ].TimeFormat )
436+ }
437+ }
0 commit comments