You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+33-27Lines changed: 33 additions & 27 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,56 +8,62 @@ A very simple utility library written in Go to log and trace a function lifecycl
8
8
9
9
## Why?
10
10
11
-
Because I'm tired of adding the same boilerplate code to every function I write, that usually requires three or more lines of code to log and trace a function and some metrics.
11
+
Because I'm tired of adding the same boilerplate code to every function I write, that usually requires three or more
12
+
lines of code to log and trace a function and some metrics.
12
13
13
14
## Usage
14
15
15
-
Just add `defer ft.Trace(ctx, "<method name>").WithError(&err).Log()`to the beginning of the function.
16
+
Just add these two lines to the beginning of the function:
|`SetDurationMetricUnit(unit string)`| Sets the global duration metric unit. Accepts either millisecond (`ms`) or second (`s`) as valid units. Defaults to millisecond if invalid unit is provided. |
54
+
|`SetDefaultLogger(l *slog.Logger)`| Sets the global logger instance. Does nothing if nil logger is provided. |
55
+
|`SetLogLevelOnFailure(level slog.Level)`| Sets the global log level for failure scenarios. |
56
+
|`SetLogLevelOnSuccess(level slog.Level)`| Sets the global log level for success scenarios. |
57
+
|`SetTracingEnabled(v bool)`| Enables or disables global tracing functionality. |
58
+
|`SetMetricsEnabled(v bool)`| Enables or disables global metrics collection. |
59
+
|`SetClock(c clockwork.Clock)`| Sets the global clock instance used for time-related operations. |
60
+
|`SetAppendOtelAttrs(v bool)`| Enables or disables the appending of OpenTelemetry attributes globally. |
55
61
56
62
## License
57
63
58
64
BSD Zero Clause License
59
65
60
-
Copyright (c) [2024][Amanbolat Balabekov]
66
+
Copyright (c) 2024Amanbolat Balabekov
61
67
62
68
Permission to use, copy, modify, and/or distribute this software for any
0 commit comments