This commit is contained in:
a 2022-11-03 10:18:09 -05:00
parent 64792032f4
commit 99eea905a5
20 changed files with 56 additions and 56 deletions

View File

@ -7,7 +7,7 @@ opinionated defaults on zerolog
# Zero Allocation JSON Logger
[![godoc](http://img.shields.io/badge/godoc-reference-blue.svg?style=flat)](https://godoc.org/git.tuxpa.in/a/zlog) [![license](http://img.shields.io/badge/license-MIT-red.svg?style=flat)](https://raw.githubusercontent.com/rs/zlog/master/LICENSE) [![Build Status](https://travis-ci.org/rs/zlog.svg?branch=master)](https://travis-ci.org/rs/zlog) [![Coverage](http://gocover.io/_badge/git.tuxpa.in/a/zlog)](http://gocover.io/git.tuxpa.in/a/zlog)
[![godoc](http://img.shields.io/badge/godoc-reference-blue.svg?style=flat)](https://godoc.org/tuxpa.in/a/zlog) [![license](http://img.shields.io/badge/license-MIT-red.svg?style=flat)](https://raw.githubusercontent.com/rs/zlog/master/LICENSE) [![Build Status](https://travis-ci.org/rs/zlog.svg?branch=master)](https://travis-ci.org/rs/zlog) [![Coverage](http://gocover.io/_badge/tuxpa.in/a/zlog)](http://gocover.io/tuxpa.in/a/zlog)
The zlog package provides a fast and simple logger dedicated to JSON output.
@ -21,7 +21,7 @@ To keep the code base and the API simple, zlog focuses on efficient structured l
## Who uses zlog
Find out [who uses zlog](https://git.tuxpa.in/a/zlog/wiki/Who-uses-zlog) and add your company / project to the list.
Find out [who uses zlog](https://tuxpa.in/a/zlog/wiki/Who-uses-zlog) and add your company / project to the list.
## Features
@ -40,21 +40,21 @@ Find out [who uses zlog](https://git.tuxpa.in/a/zlog/wiki/Who-uses-zlog) and add
## Installation
```bash
go get -u git.tuxpa.in/a/zlog/log
go get -u tuxpa.in/a/zlog/log
```
## Getting Started
### Simple Logging Example
For simple logging, import the global logger package **git.tuxpa.in/a/zlog/log**
For simple logging, import the global logger package **tuxpa.in/a/zlog/log**
```go
package main
import (
"git.tuxpa.in/a/zlog"
"git.tuxpa.in/a/zlog/log"
"tuxpa.in/a/zlog"
"tuxpa.in/a/zlog/log"
)
func main() {
@ -77,8 +77,8 @@ func main() {
package main
import (
"git.tuxpa.in/a/zlog"
"git.tuxpa.in/a/zlog/log"
"tuxpa.in/a/zlog"
"tuxpa.in/a/zlog/log"
)
func main() {
@ -108,8 +108,8 @@ func main() {
package main
import (
"git.tuxpa.in/a/zlog"
"git.tuxpa.in/a/zlog/log"
"tuxpa.in/a/zlog"
"tuxpa.in/a/zlog/log"
)
func main() {
@ -145,8 +145,8 @@ package main
import (
"flag"
"git.tuxpa.in/a/zlog"
"git.tuxpa.in/a/zlog/log"
"tuxpa.in/a/zlog"
"tuxpa.in/a/zlog/log"
)
func main() {
@ -196,8 +196,8 @@ You may choose to log without a specific level by using the `Log` method. You ma
package main
import (
"git.tuxpa.in/a/zlog"
"git.tuxpa.in/a/zlog/log"
"tuxpa.in/a/zlog"
"tuxpa.in/a/zlog/log"
)
func main() {
@ -221,8 +221,8 @@ package main
import (
"errors"
"git.tuxpa.in/a/zlog"
"git.tuxpa.in/a/zlog/log"
"tuxpa.in/a/zlog"
"tuxpa.in/a/zlog/log"
)
func main() {
@ -246,10 +246,10 @@ package main
import (
"github.com/pkg/errors"
"git.tuxpa.in/a/zlog/pkgerrors"
"tuxpa.in/a/zlog/pkgerrors"
"git.tuxpa.in/a/zlog"
"git.tuxpa.in/a/zlog/log"
"tuxpa.in/a/zlog"
"tuxpa.in/a/zlog/log"
)
func main() {
@ -293,8 +293,8 @@ package main
import (
"errors"
"git.tuxpa.in/a/zlog"
"git.tuxpa.in/a/zlog/log"
"tuxpa.in/a/zlog"
"tuxpa.in/a/zlog/log"
)
func main() {
@ -520,7 +520,7 @@ stdlog.Print("hello world")
### Integration with `net/http`
The `git.tuxpa.in/a/zlog/hlog` package provides some helpers to integrate zlog with `http.Handler`.
The `tuxpa.in/a/zlog/hlog` package provides some helpers to integrate zlog with `http.Handler`.
In this example we use [alice](https://github.com/justinas/alice) to install logger for better readability.

View File

@ -1,4 +1,4 @@
module git.tuxpa.in/a/zlog/cmd/lint
module tuxpa.in/a/zlog/cmd/lint
go 1.15

View File

@ -30,7 +30,7 @@ func init() {
flag.Parse()
// add zlog to recursively ignored packages
recursivelyIgnoredPkgs = append(recursivelyIgnoredPkgs, "git.tuxpa.in/a/zlog")
recursivelyIgnoredPkgs = append(recursivelyIgnoredPkgs, "tuxpa.in/a/zlog")
args := flag.Args()
if len(args) != 1 {
fmt.Fprintln(os.Stderr, "you must provide exactly one package path")
@ -49,14 +49,14 @@ func main() {
os.Exit(1)
}
// get the git.tuxpa.in/a/zlog.Event type
// get the tuxpa.in/a/zlog.Event type
event := getEvent(p)
if event == nil {
fmt.Fprintln(os.Stderr, "Error: git.tuxpa.in/a/zlog.Event declaration not found, maybe zlog is not imported in the scanned package?")
fmt.Fprintln(os.Stderr, "Error: tuxpa.in/a/zlog.Event declaration not found, maybe zlog is not imported in the scanned package?")
os.Exit(1)
}
// get all selections (function calls) with the git.tuxpa.in/a/zlog.Event (or pointer) receiver
// get all selections (function calls) with the tuxpa.in/a/zlog.Event (or pointer) receiver
selections := getSelectionsWithReceiverType(p, event)
// print the violations (if any)
@ -80,7 +80,7 @@ func main() {
func getEvent(p *loader.Program) types.Type {
for _, pkg := range p.AllPackages {
if strings.HasSuffix(pkg.Pkg.Path(), "git.tuxpa.in/a/zlog") {
if strings.HasSuffix(pkg.Pkg.Path(), "tuxpa.in/a/zlog") {
for _, d := range pkg.Defs {
if d != nil && d.Name() == "Event" {
return d.Type()

View File

@ -9,7 +9,7 @@ import (
"testing"
"time"
"git.tuxpa.in/a/zlog"
"tuxpa.in/a/zlog"
)
func ExampleConsoleWriter() {

View File

@ -8,7 +8,7 @@ import (
"sync"
"time"
"git.tuxpa.in/a/zlog/diode/internal/diodes"
"tuxpa.in/a/zlog/diode/internal/diodes"
)
var bufPool = &sync.Pool{

View File

@ -6,8 +6,8 @@ import (
"fmt"
"os"
"git.tuxpa.in/a/zlog"
"git.tuxpa.in/a/zlog/diode"
"tuxpa.in/a/zlog"
"tuxpa.in/a/zlog/diode"
)
func ExampleNewWriter() {

View File

@ -9,9 +9,9 @@ import (
"testing"
"time"
"git.tuxpa.in/a/zlog"
"git.tuxpa.in/a/zlog/diode"
"git.tuxpa.in/a/zlog/internal/cbor"
"tuxpa.in/a/zlog"
"tuxpa.in/a/zlog/diode"
"tuxpa.in/a/zlog/internal/cbor"
)
func TestNewWriter(t *testing.T) {

View File

@ -5,7 +5,7 @@ package zlog
// This file contains bindings to do binary encoding.
import (
"git.tuxpa.in/a/zlog/internal/cbor"
"tuxpa.in/a/zlog/internal/cbor"
)
var (

View File

@ -6,7 +6,7 @@ package zlog
// JSON encoded byte stream.
import (
"git.tuxpa.in/a/zlog/internal/json"
"tuxpa.in/a/zlog/internal/json"
)
var (

View File

@ -7,9 +7,9 @@ import (
"time"
"github.com/rs/xid"
"git.tuxpa.in/a/zlog"
"git.tuxpa.in/a/zlog/hlog/internal/mutil"
"git.tuxpa.in/a/zlog/log"
"tuxpa.in/a/zlog"
"tuxpa.in/a/zlog/hlog/internal/mutil"
"tuxpa.in/a/zlog/log"
)
// FromRequest gets the logger in the request's context.

View File

@ -9,8 +9,8 @@ import (
"net/http/httptest"
"git.tuxpa.in/a/zlog"
"git.tuxpa.in/a/zlog/hlog"
"tuxpa.in/a/zlog"
"tuxpa.in/a/zlog/hlog"
)
// fake alice to avoid dep

View File

@ -14,8 +14,8 @@ import (
"testing"
"github.com/rs/xid"
"git.tuxpa.in/a/zlog"
"git.tuxpa.in/a/zlog/internal/cbor"
"tuxpa.in/a/zlog"
"tuxpa.in/a/zlog/internal/cbor"
)
func decodeIfBinary(out *bytes.Buffer) string {

View File

@ -8,7 +8,7 @@ import (
"os"
"time"
"git.tuxpa.in/a/zlog"
"tuxpa.in/a/zlog"
)
func writeLog(fname string, count int, useCompress bool) {

View File

@ -25,8 +25,8 @@ import (
"strings"
"github.com/coreos/go-systemd/v22/journal"
"git.tuxpa.in/a/zlog"
"git.tuxpa.in/a/zlog/internal/cbor"
"tuxpa.in/a/zlog"
"tuxpa.in/a/zlog/internal/cbor"
)
const defaultJournalDPrio = journal.PriNotice

View File

@ -7,8 +7,8 @@ import (
"io"
"testing"
"git.tuxpa.in/a/zlog"
"git.tuxpa.in/a/zlog/journald"
"tuxpa.in/a/zlog"
"tuxpa.in/a/zlog/journald"
)
func ExampleNewJournalDWriter() {

4
log.go
View File

@ -2,12 +2,12 @@
//
// A global Logger can be use for simple logging:
//
// import "git.tuxpa.in/a/zlog/log"
// import "tuxpa.in/a/zlog/log"
//
// log.Info().Msg("hello world")
// // Output: {"time":1494567715,"level":"info","message":"hello world"}
//
// NOTE: To import the global logger, import the "log" subpackage "git.tuxpa.in/a/zlog/log".
// NOTE: To import the global logger, import the "log" subpackage "tuxpa.in/a/zlog/log".
//
// Fields can be added to log messages:
//

View File

@ -8,7 +8,7 @@ import (
"os"
"time"
"git.tuxpa.in/a/zlog"
"tuxpa.in/a/zlog"
)
// Logger is the global logger.

View File

@ -9,8 +9,8 @@ import (
"os"
"time"
"git.tuxpa.in/a/zlog"
"git.tuxpa.in/a/zlog/log"
"tuxpa.in/a/zlog"
"tuxpa.in/a/zlog/log"
)
// setup would normally be an init() function, however, there seems

View File

@ -10,7 +10,7 @@ import (
"os"
"time"
"git.tuxpa.in/a/zlog"
"tuxpa.in/a/zlog"
)
func ExampleNew() {

View File

@ -8,7 +8,7 @@ import (
"testing"
"github.com/pkg/errors"
"git.tuxpa.in/a/zlog"
"tuxpa.in/a/zlog"
)
func TestLogStack(t *testing.T) {