Home / File/ logger.go — fiber Source File

logger.go — fiber Source File

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

File go FiberCore Adapters 1 imports 1 functions 2 classes

Entity Profile

Dependency Diagram

graph LR
  c05699f8_10c4_dc5d_e4d2_14ff886537f1["logger.go"]
  8759af17_0eaa_9de8_b2fe_8f672f58a010["os"]
  c05699f8_10c4_dc5d_e4d2_14ff886537f1 --> 8759af17_0eaa_9de8_b2fe_8f672f58a010
  style c05699f8_10c4_dc5d_e4d2_14ff886537f1 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

package logger

import (
	"os"
	"strconv"
	"strings"
	"sync"
	"sync/atomic"
	"time"

	"github.com/gofiber/fiber/v3"
)

// New creates a new middleware handler
func New(config ...Config) fiber.Handler {
	// Set default config
	cfg := configDefault(config...)

	// Get timezone location
	tz, err := time.LoadLocation(cfg.TimeZone)
	if err != nil || tz == nil {
		cfg.timeZoneLocation = time.Local
	} else {
		cfg.timeZoneLocation = tz
	}

	// Check if format contains latency
	cfg.enableLatency = strings.Contains(cfg.Format, "${"+TagLatency+"}")

	var timestamp atomic.Value
	// Create correct timeformat
	timestamp.Store(time.Now().In(cfg.timeZoneLocation).Format(cfg.TimeFormat))

	// Update date/time every 500 milliseconds in a separate go routine
	if strings.Contains(cfg.Format, "${"+TagTime+"}") {
		go func() {
			for {
				time.Sleep(cfg.TimeInterval)
				timestamp.Store(time.Now().In(cfg.timeZoneLocation).Format(cfg.TimeFormat))
			}
		}()
	}
	// Set PID once
	pid := strconv.Itoa(os.Getpid())

	// Set variables
	var (
		once       sync.Once
		errHandler fiber.ErrorHandler

		dataPool = sync.Pool{New: func() any { return new(Data) }}
	)

	// Err padding
	errPadding := 15
	errPaddingStr := strconv.Itoa(errPadding)

	// Before handling func
	cfg.BeforeHandlerFunc(&cfg)

// ... (68 more lines)

Domain

Subdomains

Functions

Classes

Dependencies

  • os

Frequently Asked Questions

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

Analyze Your Own Codebase

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

Try Supermodel Free