Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/pieterclaerhout/go-log
A logging library with strack traces, object dumping and optional timestamps
https://github.com/pieterclaerhout/go-log
dumping golang golang-library golang-package logging stacktrace
Last synced: 14 days ago
JSON representation
A logging library with strack traces, object dumping and optional timestamps
- Host: GitHub
- URL: https://github.com/pieterclaerhout/go-log
- Owner: pieterclaerhout
- License: apache-2.0
- Created: 2019-10-01T08:55:38.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2024-06-24T06:09:18.000Z (5 months ago)
- Last Synced: 2024-07-31T20:52:12.983Z (3 months ago)
- Topics: dumping, golang, golang-library, golang-package, logging, stacktrace
- Language: Go
- Size: 76.2 KB
- Stars: 10
- Watchers: 4
- Forks: 5
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-go - go-log - A logging library with stack traces, object dumping and optional timestamps. (Logging / Search and Analytic Databases)
- awesome-go-extra - go-log - 10-01T08:55:38Z|2020-07-08T07:39:26Z| (Logging / Advanced Console UIs)
README
## go-log
[![Build Status](https://img.shields.io/github/workflow/status/pieterclaerhout/go-log/Go)](https://github.com/pieterclaerhout/go-log/actions?query=workflow%3AGo)
[![Go Report Card](https://goreportcard.com/badge/github.com/pieterclaerhout/go-log)](https://goreportcard.com/report/github.com/pieterclaerhout/go-log)
[![Documentation](https://godoc.org/github.com/pieterclaerhout/go-log?status.svg)](http://godoc.org/github.com/pieterclaerhout/go-log)
[![license](https://img.shields.io/badge/license-Apache%20v2-orange.svg)](https://github.com/pieterclaerhout/go-log/raw/master/LICENSE)
[![GitHub version](https://badge.fury.io/gh/pieterclaerhout%2Fgo-log.svg)](https://badge.fury.io/gh/pieterclaerhout%2Fgo-log)
[![GitHub issues](https://img.shields.io/github/issues/pieterclaerhout/go-log.svg)](https://github.com/pieterclaerhout/go-log/issues)This is a [Golang](https://golang.org) library with logging related functions which I use in my different projects.
## Usage
```go
package mainimport (
"github.com/pieterclaerhout/go-log"
)func main() {
log.DebugMode = true
log.PrintTimestamp = true
log.PrintColors = true
log.TimeFormat = "2006-01-02 15:04:05.000"myVar := map[string]string{"hello": "world"}
log.Debug("arg1", "arg2")
log.Debugf("arg1 %d", 1)
log.DebugDump(myVar, "prefix")
log.DebugSeparator("title")log.Info("arg1", "arg2")
log.Infof("arg1 %d", 1)
log.InfoDump(myVar, "prefix")
log.InfoSeparator("title")log.Warn("arg1", "arg2")
log.Warnf("arg1 %d", 1)
log.WarnDump(myVar, "prefix")
log.WarnSeparator("title")log.Error("arg1", "arg2")
log.Errorf("arg1 %d", 1)
log.ErrorDump(myVar, "prefix")
log.ErrorSeparator("title")log.Fatal("arg1", "arg2")
log.Fatalf("arg1 %d", 1)err1 := funcWithError()
log.StackTrace(err1)err2 := funcWithError()
log.CheckError(err2)}
```## Environment variables
The defaults are taken from the environment variables:
* `DEBUG`: `log.DebugMode`
* `PRINT_TIMESTAMP`: `log.PrintTimestamp`