noagin

package module
v1.0.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 15, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

README

Noa Gin

The Gin integration module for Noa Log, allowing quick integration of Noa into the Gin framework.

Installation

go get -u github.com/noa-log/noa-gin

Quick Start

package main

import (
    "os"
    "github.com/gin-gonic/gin"
    "github.com/noa-log/noa"
    noagin "github.com/noa-log/noa-gin"
)

func main() {
    // Create a new logger instance
    logger := noa.NewLog()

    // Create a Gin engine instance
    gin.DefaultWriter = os.Stdin // Disable Gin's default log output
    r := gin.Default()

    // Use Noa handle
    r.Use(noagin.LogHandle(logger))

    r.GET("/", func(c *gin.Context) {
        c.String(200, "Hello, Noa!")
    })

    if err := r.Run(":8080"); err != nil {
        logger.Error("Gin", err)
    }
}

License

This project is open-sourced under the Apache License 2.0. Please comply with the terms when using it.

Documentation

Overview

* @Author: nijineko * @Date: 2025-06-09 13:08:32 * @LastEditTime: 2025-06-11 11:59:24 * @LastEditors: nijineko * @Description: noa gin handle * @FilePath: \noa-gin\handle.go

* @Author: nijineko * @Date: 2025-06-09 13:48:25 * @LastEditTime: 2025-06-09 13:51:47 * @LastEditors: nijineko * @Description: request method utility * @FilePath: \noa-gin\requestMethod.go

* @Author: nijineko * @Date: 2025-06-09 13:46:06 * @LastEditTime: 2025-06-09 13:47:15 * @LastEditors: nijineko * @Description: status code utility * @FilePath: \noa-gin\statusCode.go

Index

Constants

This section is empty.

Variables

View Source
var (
	DEFAULT_LOG_SOURCE = "Gin"
)

Functions

func LogHandle

func LogHandle(Log *noa.LogConfig) gin.HandlerFunc

*

  • @description: log handle
  • @param {*noa.LogConfig} Log noa log instance
  • @return {gin.HandlerFunc} gin handler function

func RequestMethodColor

func RequestMethodColor(method string) string

*

  • @description: format request method with color
  • @param {string} method HTTP request method
  • @return {string} formatted request method with color

func StatusCodeColor

func StatusCodeColor(statusCode int) string

*

  • @description: format status code with color
  • @param {int} statusCode HTTP status code
  • @return {string} formatted status code with color

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL