Skip to content

zcubbs/charmlogfiber

Repository files navigation

Fiber Middleware for charmbracelet/log

A GoFiber middleware for Charmlog logger.

tag Go Version GoDoc Lint Scan Build Status Go Report Card Contributors License

Usage

package main

import (
    "github.com/gofiber/fiber/v2"
    "github.com/charmbracelet/log"
    "github.com/zcubbs/charmlogfiber"
    "os"
)

func main() {
    app := fiber.New()

    logger := log.New(os.Stderr)
    // Create a new logger
    fiberLogger := charmlogfiber.New(logger)

    // Use the logger in the Fiber app
    app.Use(fiberLogger)

    app.Get("/", func(c *fiber.Ctx) error {
        // Log a message
        logger.Info("Hello, World!")

        return c.SendString("Hello, World!")
    })

    app.Listen(":3000")
}