A customized GORM logger that implements the appropriate interface and uses Logrus to output logs

CryptoMath GORM Logger

A customized GORM logger that implements the appropriate interface and uses Logrus to output logs.

Install

go get github.com/mathandcrypto/cryptomath-gorm-logger

Basic usage

package main

import (
    "github.com/mathandcrypto/cryptomath-gorm-logger"
    "github.com/sirupsen/logrus"
    "gorm.io/driver/sqlite"
    "gorm.io/gorm"
    gormLogger "gorm.io/gorm/logger"
)

func main() {
    log := logrus.New()
    newLogger := logger.New(log, gormLogger.Config{
        SlowThreshold:  time.Second,    // Slow SQL threshold
        SkipErrRecordNotFound: true,    // Skip ErrRecordNotFound error for logger
        SourceField:    "source",    //  Source field in config which is recorded file name and line number of the current error
        ModuleName:     "my-gorm-logger",    // Name of the module in the log. Default value: "gorm"
        LogLevel:   logger.Error, // Log level. Default value: gormLogger.Info
    })

    db, err := gorm.Open(sqlite.Open("test.db"), &gorm.Config{
        Logger: newLogger,
    })
}

License

© CryptoMath, since 2021

Released under the MIT License

Owner
Crypto Math
The CryptoMath project
Crypto Math
Similar Resources

Go logger interface adapter

Glog glog is an abstraction for various Go language log libraries. The Logger interface is in maintenance-mode to prevent broken changes to projects b

Nov 17, 2021

Logger - Go language is interface-oriented to implement an asynchronous log writing program

logger日志库 1、安装 go get github.com/staryjie/logger@latest 2、使用 示例: package main import ( "github.com/staryjie/logger" "time" ) func initLogger(name,

Jan 4, 2022

Go-zla - Zerolog adapter to go-facades logger interface

GO-ZLA GO ZeroLog Adapter (a.k.a. go-zla) is a lightweight Golang module that ad

Feb 16, 2022

The open and composable observability and data visualization platform. Visualize metrics, logs, and traces from multiple sources like Prometheus, Loki, Elasticsearch, InfluxDB, Postgres and many more.

The open and composable observability and data visualization platform. Visualize metrics, logs, and traces from multiple sources like Prometheus, Loki, Elasticsearch, InfluxDB, Postgres and many more.

The open-source platform for monitoring and observability. Grafana allows you to query, visualize, alert on and understand your metrics no matter wher

Jan 3, 2023

Library and program to parse and forward HAProxy logs

haminer Library and program to parse and forward HAProxy logs. Supported forwarder, Influxdb Requirements Go for building from source code git for dow

Aug 17, 2022

Pixie gives you instant visibility by giving access to metrics, events, traces and logs without changing code.

Pixie gives you instant visibility by giving access to metrics, events, traces and logs without changing code.

Pixie gives you instant visibility by giving access to metrics, events, traces and logs without changing code.

Jan 4, 2023

Search and analysis tooling for structured logs

Zed The Zed system provides an open-source, cloud-native, and searchable data lake for semi-structured and structured data. Zed lakes utilize a supers

Jan 5, 2023

Golog is a logger which support tracing and other custom behaviors out of the box. Blazing fast and simple to use.

GOLOG Golog is an opinionated Go logger with simple APIs and configurable behavior. Why another logger? Golog is designed to address mainly two issues

Oct 2, 2022

Leveled execution logs for Go

glog ==== Leveled execution logs for Go. This is an efficient pure Go implementation of leveled logs in the manner of the open source C++ package h

Dec 24, 2022
Go-logging-logrus - Learn how to log management in golang with logrus

Learn how to logging in golang with logrus How to run this project git clone htt

Jan 19, 2022
Convenient Logger interface and std logger wrapper

Convenient logger interface and wrapper around std logger Interface type Logger interface { Error(err error) Debugf(format string, args ...interface

Nov 28, 2021
Loggly Hooks for GO Logrus logger

Loggly Hooks for Logrus Usage package main import ( "github.com/sirupsen/logrus" "github.com/sebest/logrusly" ) var logglyToken string = "YOUR_LOG

Sep 26, 2022
Binalyze logger is an easily customizable wrapper for logrus with log rotation

logger logger is an easily customizable wrapper for logrus with log rotation Usage There is only one function to initialize logger. logger.Init() When

Oct 2, 2022
Logger - Some implementations for Logs written in Go

Logger will be a tool for sending logs to different places in your software. Rig

Feb 16, 2022
Logger - Simple logger without written with std pkg

Go-Logger Simple usage is: package main

Jan 2, 2022
Logger - A thin wrapper of uber-go/zap logger for personal project

a thin wraper of uber-go/zap logger for personal project 0. thanks uber-go/zap B

Sep 17, 2022
This package enables json output, level logging and so on to standard go logger.

logplug This package enables json output, level logging and so on to standard logger. Usage log.SetOutput(logplug.NewJSONPlug(os.Stderr, logplug.LogF

Dec 27, 2021
Secure logger in Go to avoid output sensitive data in log
Secure logger in Go to avoid output sensitive data in log

zlog A main distinct feature of zlog is secure logging that avoid to output secret/sensitive values to log. The feature reduce risk to store secret va

Dec 6, 2022
Logrus is a structured, pluggable logging for Go.
Logrus is a structured, pluggable logging for Go.

Logrus is a structured logger for Go (golang), completely API compatible with the standard library logger.

May 25, 2021