Skip to content

Commit

Permalink
update implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
paul-carlton committed Oct 27, 2024
1 parent fcb21a8 commit 66f7a68
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions pkg/logging/logging.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,11 @@ var (
)

func init() {
fmt.Printf("creating trace logger\n")
traceLog = traceLogger()
fmt.Printf("created trace logger...\n%+v\n", traceLog)
sourcePathDepth = setSourcePathDepth()
logSource = setSource()
LogLevel = setLogLevel()
fmt.Printf("Logging level: %d\n", LogLevel)
traceLog = traceLogger()
}

// setLogLevel returns the logging level selected by the user.
Expand Down Expand Up @@ -161,7 +160,6 @@ func setCallerSourceName(a slog.Attr) slog.Attr {
// setSourceName is used to set to source file name, specifically the number of elements of the directory path to include.
func setSourceName(a slog.Attr) slog.Attr {
if a.Key == slog.SourceKey { //nolint: nestif
sourcePathDepth := setSourcePathDepth()
if sourcePathDepth >= 0 {
source, ok := a.Value.Any().(*slog.Source)
if !ok {
Expand Down Expand Up @@ -219,9 +217,7 @@ func traceLogger() *slog.Logger {
return a
},
}

handler := slog.NewJSONHandler(os.Stdout, opts)
fmt.Printf("created trace handler...\n%+v\n", handler)
return slog.New(handler)
}

Expand Down Expand Up @@ -361,7 +357,6 @@ func CallerText(skip int) string {
// TraceCall traces calls and exit for functions.
func TraceCall() {
ctx := context.Background()
fmt.Printf("Called TraceCall\n")
traceLog.Log(ctx, LevelTrace, "Entering function")
}

Expand Down

0 comments on commit 66f7a68

Please sign in to comment.