Home / File/ default.go — fiber Source File

default.go — fiber Source File

Architecture documentation for default.go, a go file in the fiber codebase. 1 imports, 0 dependents.

File go FiberCore Routing 1 imports 1 functions

Entity Profile

Dependency Diagram

graph LR
  f8a95d0e_bea0_70d8_ecc9_6b86910c8e43["default.go"]
  cc7104af_aece_1fe5_3985_791c7f34910c["context"]
  f8a95d0e_bea0_70d8_ecc9_6b86910c8e43 --> cc7104af_aece_1fe5_3985_791c7f34910c
  style f8a95d0e_bea0_70d8_ecc9_6b86910c8e43 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

package log

import (
	"context"
	"fmt"
	"io"
	"log"
	"os"

	"github.com/gofiber/utils/v2"
	"github.com/valyala/bytebufferpool"
)

var _ AllLogger[*log.Logger] = (*defaultLogger)(nil)

type defaultLogger struct {
	stdlog *log.Logger
	level  Level
	depth  int
}

// privateLog logs a message at a given level log the default logger.
// when the level is fatal, it will exit the program.
func (l *defaultLogger) privateLog(lv Level, fmtArgs []any) {
	if l.level > lv {
		return
	}
	level := lv.toString()
	buf := bytebufferpool.Get()
	buf.WriteString(level)
	fmt.Fprint(buf, fmtArgs...)

	_ = l.stdlog.Output(l.depth, buf.String()) //nolint:errcheck // It is fine to ignore the error
	if lv == LevelPanic {
		panic(buf.String())
	}

	buf.Reset()
	bytebufferpool.Put(buf)
	if lv == LevelFatal {
		os.Exit(1) //nolint:revive // we want to exit the program when Fatal is called
	}
}

// privateLogf logs a formatted message at a given level log the default logger.
// when the level is fatal, it will exit the program.
func (l *defaultLogger) privateLogf(lv Level, format string, fmtArgs []any) {
	if l.level > lv {
		return
	}
	level := lv.toString()
	buf := bytebufferpool.Get()
	buf.WriteString(level)

	if len(fmtArgs) > 0 {
		_, _ = fmt.Fprintf(buf, format, fmtArgs...)
	} else {
		_, _ = fmt.Fprint(buf, format)
	}

// ... (195 more lines)

Domain

Subdomains

Functions

Dependencies

  • context

Frequently Asked Questions

What does default.go do?
default.go is a source file in the fiber codebase, written in go. It belongs to the FiberCore domain, Routing subdomain.
What functions are defined in default.go?
default.go defines 1 function(s): DefaultLogger.
What does default.go depend on?
default.go imports 1 module(s): context.
Where is default.go in the architecture?
default.go is located at log/default.go (domain: FiberCore, subdomain: Routing, directory: log).

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free