@@ -74,8 +74,8 @@ func TestParseLogFormat(t *testing.T) {
7474 {"json uppercase" , "JSON" , FormatJSON , false },
7575 {"json mixed case" , "Json" , FormatJSON , false },
7676 {"with whitespace" , " json " , FormatJSON , false },
77- {"invalid format" , "xml" , FormatText , true },
78- {"empty string" , "" , FormatText , true },
77+ {"invalid format" , "xml" , FormatJSON , true },
78+ {"empty string" , "" , FormatJSON , true },
7979 }
8080
8181 for _ , tt := range tests {
@@ -89,9 +89,9 @@ func TestParseLogFormat(t *testing.T) {
8989 if err != nil {
9090 t .Errorf ("unexpected error for input %q: %v" , tt .input , err )
9191 }
92- if format != tt . expected {
93- t . Errorf ( "expected %v, got %v" , tt .expected , format )
94- }
92+ }
93+ if format != tt .expected {
94+ t . Errorf ( "expected %v, got %v" , tt . expected , format )
9595 }
9696 })
9797 }
@@ -595,8 +595,8 @@ func TestDefaultConfig(t *testing.T) {
595595 if cfg .Level != LevelInfo {
596596 t .Errorf ("expected default level to be Info, got %v" , cfg .Level )
597597 }
598- if cfg .Format != FormatText {
599- t .Errorf ("expected default format to be Text , got %v" , cfg .Format )
598+ if cfg .Format != FormatJSON {
599+ t .Errorf ("expected default format to be JSON , got %v" , cfg .Format )
600600 }
601601 if cfg .Output != os .Stdout {
602602 t .Error ("expected default output to be stdout" )
@@ -809,3 +809,16 @@ func TestLoggerErrorWithStackTrace(t *testing.T) {
809809 }
810810 })
811811}
812+
813+ func TestDefaultFormatIsJSON (t * testing.T ) {
814+ var buf bytes.Buffer
815+ cfg := DefaultConfig ()
816+ cfg .Output = & buf
817+ log := NewHyperFleetLoggerWithConfig (cfg )
818+
819+ log .Info (context .Background (), "test" )
820+
821+ if ! json .Valid (buf .Bytes ()) {
822+ t .Errorf ("expected default format output to be valid JSON, got: %s" , buf .String ())
823+ }
824+ }
0 commit comments