hclog-zerolog

A wrapper for zerolog to use it as an instance of Hahicorp hclog.Logger.

https://github.com/psapezhka/hclog-zerolog

Science Score: 44.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
    Found CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
  • Academic publication links
  • Academic email domains
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (10.7%) to scientific vocabulary

Keywords

golang hclog logging zerolog
Last synced: 6 months ago · JSON representation ·

Repository

A wrapper for zerolog to use it as an instance of Hahicorp hclog.Logger.

Basic Info
  • Host: GitHub
  • Owner: psapezhka
  • License: mpl-2.0
  • Language: Go
  • Default Branch: main
  • Homepage:
  • Size: 71.3 KB
Statistics
  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • Open Issues: 1
  • Releases: 2
Topics
golang hclog logging zerolog
Created 11 months ago · Last pushed 10 months ago
Metadata Files
Readme Contributing Funding License Code of conduct Citation Security Authors

README.md

hclog-zerolog

[![Go Report Card](https://goreportcard.com/badge/github.com/weastur/hclog-zerolog)](https://goreportcard.com/report/github.com/weastur/hclog-zerolog) [![codecov](https://codecov.io/gh/weastur/hclog-zerolog/graph/badge.svg?token=V94BPHSLB0)](https://codecov.io/gh/weastur/hclog-zerolog) [![test](https://github.com/weastur/hclog-zerolog/actions/workflows/test.yaml/badge.svg)](https://github.com/weastur/hclog-zerolog/actions/workflows/test.yaml) [![lint](https://github.com/weastur/hclog-zerolog/actions/workflows/lint.yaml/badge.svg)](https://github.com/weastur/hclog-zerolog/actions/workflows/lint.yaml)
![GitHub Release](https://img.shields.io/github/v/release/weastur/hclog-zerolog) ![GitHub commits since latest release](https://img.shields.io/github/commits-since/weastur/hclog-zerolog/latest) ![GitHub go.mod Go version](https://img.shields.io/github/go-mod/go-version/weastur/hclog-zerolog) ![GitHub License](https://img.shields.io/github/license/weastur/hclog-zerolog)

hclog-zerolog is a wrapper for zerolog to use it as an implementation of hclog.Logger interface

Why?

Working on project with hashicorp raft inside, which is producing a lot of logs while running, I faced with the need to implement hclog.Logger compatible zerolog wrapper, to be able to organize logging in my app in homogeneous way.

Nothing complicated here, but implementing of 20+ methods just to normalize logging in your app could be a bit tiring, so sharing my wrapper.

Installation

bash go get -u github.com/weastur/hclog-zerolog

Usage

Using hashicorp raft as an example of a library depending of hclog.Logger. Of course, it could be anything else.

```go import ( "github.com/hashicorp/raft" "github.com/rs/zerolog/log" hclogzerolog "github.com/weastur/hclog-zerolog" )

raftLogger := log.With().Str("component", "raft").Logger() config := raft.DefaultConfig() config.Logger = hclogzerolog.New(raftLogger) ```

Despite it's extremely simple, you can refer to the example and godoc to see a bit more.

Contributing

Contributions are welcome! Please read the CONTRIBUTING.md file for details on how to contribute to this project.

Security

Refer to the SECURITY.md file for more information.

License

Mozilla Public License 2.0

Refer to the LICENSE file for more information.

Citation (CITATION.cff)

cff-version: 1.2.0
message: "If you use this software, please cite it as below."
title: "Asset Manager"
version: "v1.0.0"
type: software
authors:
  - family-names: "Sapezhka"
    given-names: "Pavel"
doi: 10.5281/zenodo.1234
date-released: 2025-03-23
url: "https://github.com/weastur/hclog-zerolog"
repository-code: "https://github.com/weastur/hclog-zerolog"
abstract: >-
  A simple wrapper for zerolog to use it as an instance of Hahicorp hclog logger.
keywords:
  - go
  - zerolog
  - hclog
  - logging
license: MPL-2.0

GitHub Events

Total
Last Year

Dependencies

_example/go.mod go
  • github.com/armon/go-metrics v0.4.1
  • github.com/fatih/color v1.18.0
  • github.com/hashicorp/go-hclog v1.6.3
  • github.com/hashicorp/go-immutable-radix v1.0.0
  • github.com/hashicorp/go-metrics v0.5.4
  • github.com/hashicorp/go-msgpack/v2 v2.1.2
  • github.com/hashicorp/golang-lru v0.5.0
  • github.com/hashicorp/raft v1.7.3
  • github.com/mattn/go-colorable v0.1.14
  • github.com/mattn/go-isatty v0.0.20
  • github.com/rs/zerolog v1.34.0
  • github.com/weastur/hclog-zerolog v0.0.0-20250326084749-0cd2cf1dcb32
  • golang.org/x/sys v0.31.0
_example/go.sum go
  • 176 dependencies
go.sum go
  • github.com/coreos/go-systemd/v22 v22.3.2
  • github.com/davecgh/go-spew v1.1.1
  • github.com/fatih/color v1.7.0
  • github.com/fatih/color v1.13.0
  • github.com/godbus/dbus/v5 v5.0.4
  • github.com/hashicorp/go-hclog v1.0.0
  • github.com/mattn/go-colorable v0.1.4
  • github.com/mattn/go-colorable v0.1.9
  • github.com/mattn/go-colorable v0.1.13
  • github.com/mattn/go-isatty v0.0.8
  • github.com/mattn/go-isatty v0.0.10
  • github.com/mattn/go-isatty v0.0.12
  • github.com/mattn/go-isatty v0.0.14
  • github.com/mattn/go-isatty v0.0.16
  • github.com/mattn/go-isatty v0.0.19
  • github.com/pkg/errors v0.9.1
  • github.com/pmezard/go-difflib v1.0.0
  • github.com/rs/xid v1.3.0
  • github.com/rs/zerolog v1.25.0
  • github.com/stretchr/testify v1.2.2
  • github.com/yuin/goldmark v1.3.5
  • golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2
  • golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550
  • golang.org/x/mod v0.4.2
  • golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3
  • golang.org/x/net v0.0.0-20190620200207-3b0461eec859
  • golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4
  • golang.org/x/sync v0.0.0-20190423024810-112230192c58
  • golang.org/x/sync v0.0.0-20210220032951-036812b2e83c
  • golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a
  • golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223
  • golang.org/x/sys v0.0.0-20190412213103-97732733099d
  • golang.org/x/sys v0.0.0-20191008105621-543471e840be
  • golang.org/x/sys v0.0.0-20200116001909-b77594299b42
  • golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae
  • golang.org/x/sys v0.0.0-20201119102817-f84b799fce68
  • golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44
  • golang.org/x/sys v0.0.0-20210510120138-977fb7262007
  • golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c
  • golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab
  • golang.org/x/sys v0.6.0
  • golang.org/x/sys v0.12.0
  • golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1
  • golang.org/x/text v0.3.0
  • golang.org/x/text v0.3.3
  • golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e
  • golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e
  • golang.org/x/tools v0.1.5
  • golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7
  • golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898
  • golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1
.github/workflows/lint.yaml actions
  • actions/checkout v4 composite
  • actions/setup-go v5 composite
  • golangci/golangci-lint-action v6 composite
.github/workflows/test.yaml actions
  • actions/checkout v4 composite
  • actions/setup-go v5 composite
  • codecov/codecov-action v5 composite
go.mod go