File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -151,6 +151,20 @@ func String(key, val string) Field {
151151 return Field {key : key , typ : StringType , strVal : val }
152152}
153153
154+ // Stringf constructs a Field carrying a formatted string value.
155+ //
156+ // Parameters:
157+ // - `key`: the field name
158+ // - `format`: the format string
159+ // - `args`: the arguments to format
160+ //
161+ // Returns:
162+ //
163+ // a Field of type StringType.
164+ func Stringf (key , format string , args ... any ) Field {
165+ return Field {key : key , typ : StringType , strVal : fmt .Sprintf (format , args ... )}
166+ }
167+
154168// Bool constructs a Field carrying a bool value.
155169//
156170// Parameters:
Original file line number Diff line number Diff line change @@ -58,6 +58,11 @@ func Error(msg string, fields ...Field) {
5858 GlobalLogger ().dispatch (ErrorLevel , msg , fields ... )
5959}
6060
61+ // Fatal logs a FATAL-level message via the global logger.
62+ func Fatal (msg string , fields ... Field ) {
63+ GlobalLogger ().dispatch (FatalLevel , msg , fields ... )
64+ }
65+
6166// Tracef logs a TRACE-level formatted message via the global logger.
6267func Tracef (format string , args ... any ) {
6368 GlobalLogger ().Tracef (format , args ... )
@@ -83,6 +88,11 @@ func Errorf(format string, args ...any) {
8388 GlobalLogger ().Errorf (format , args ... )
8489}
8590
91+ // Fatalf logs a FATAL-level formatted message via the global logger.
92+ func Fatalf (format string , args ... any ) {
93+ GlobalLogger ().Fatalf (format , args ... )
94+ }
95+
8696// GlobalWithContextFields returns a new context that carries the provided fields for
8797// use with the global logger.
8898func GlobalWithContextFields (ctx context.Context , fields ... Field ) context.Context {
You can’t perform that action at this time.
0 commit comments