- Update Drone CI configuration to include triggers for push and tag events. - Improve test coverage commands and add coverage checks. - Introduce release notes generation and packaging steps in the CI pipeline. - Add comprehensive release documentation and a checklist for the release process. - Implement tests for GELF logging functionality. - Update dependencies in go.mod and go.sum for better compatibility. - Add scripts for checking coverage and generating release notes. |
||
|---|---|---|
| .githooks | ||
| docs | ||
| scripts | ||
| .drone.yml | ||
| .editorconfig | ||
| .gitattributes | ||
| .gitignore | ||
| AGENTS.md | ||
| LICENSE | ||
| README.md | ||
| gelflogger.go | ||
| gelflogger_test.go | ||
| go.mod | ||
| go.sum | ||
README.md
Go GELF Logging Library
Minimal helper package to send application logs to Graylog via GELF while still writing to the standard Go logger.
Overview
This module wraps gopkg.in/aphistic/golf.v0 and exposes a small API for common log levels.
Behavior summary:
- If GELF is configured with
SetDefaultConfig, messages are sent to Graylog over UDP. - Messages are also written to the standard Go logger (
logpackage). - If GELF is not configured, logging still works locally via the standard logger.
Installation
go get scm.yoorie.de/go-lib/gelf
Quick Start
package main
import (
"scm.yoorie.de/go-lib/gelf"
)
func main() {
gelf.SetDefaultConfig("graylog.example.local", 12201,
map[string]interface{}{
"service": "billing-api",
"env": "prod",
},
)
gelf.Info("service started")
gelf.Infof("listening on %s", ":8080")
gelf.Alert("database latency is high")
}
API
Configuration
SetDefaultConfig(host string, port int, attrs map[string]interface{})
Creates and configures the default GELF logger. Attributes in
attrs are attached as default fields to all GELF messages.
Logging Functions
Debug(msg string)Debugf(format string, va ...interface{})Info(msg string)Infof(format string, va ...interface{})Alert(msg string)Alertf(format string, va ...interface{})Fatal(msg string)Fatalf(format string, va ...interface{})
Notes
FatalandFatalfterminate the program by callinglog.Fatalf.- Graylog delivery uses UDP (
udp://host:port). - Calling
SetDefaultConfigagain replaces the previous client.
Development
Run tests:
go test ./...
Module information is defined in go.mod.
Additional Documentation
License
See LICENSE.
Copyright © 2023 yoorie.de