logger

package module
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 21, 2023 License: MIT Imports: 7 Imported by: 0

README

Zerolog-GCP-Integration

Zerolog-GCP-Integration is a module for integrating Zerolog with Google Cloud Platform (GCP). It enables Golang applications to push log events to GCP's Cloud Logging, enhancing monitoring and troubleshooting capabilities.

Features

  • Seamlessly integrates with Zerolog
  • Log events are directly pushed to Google Cloud's Cloud Logging
  • Offers different log levels for enhanced debugging and information tracking
  • Compatible with OpenTelemetry's trace API

Installation

go get github.com/program-world-labs/zerolog-gcp

Usage

Import the package into your project and use it to create a new logger:

import (
    "github.com/program-world-labs/zerolog-gcp"
)

func main() {
    log := logger.NewProductionLogger("<your_project_id>")
    log.Info().Msg("This is an info message")

    // or for development
    log := logger.NewDevelopmentLogger("<your_project_id>")
    log.Debug().Msg("This is a debug message")
}

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

License

MIT

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Event

type Event struct {
	*zerolog.Event
}

type Interface

type Interface interface {
	Trace() *Event
	Debug() *Event
	Info() *Event
	Warn() *Event
	Error() *Event
	Fatal() *Event
	Panic() *Event
	Err(error) *Event
	Log() *Event
	Span(trace.Span) *Event
	ErrorSpan(trace.Span) *Event
	Print(...interface{})
	Printf(string, ...interface{})
	Write(p []byte) (n int, err error)
	Output(io.Writer) Logger
}

Interface -.

type Logger

type Logger struct {
	*zerolog.Logger
	// contains filtered or unexported fields
}

func NewDevelopmentLogger

func NewDevelopmentLogger(projectID string) *Logger

NewDevelopmentLogger returns a configured logger for development. It outputs debug level and above logs without sampling. The logger is configured to output logs in the format expected by Google Cloud Logging. The projectID parameter specifies the ID of the Google Cloud project to which the logs will be sent.

func NewProductionLogger

func NewProductionLogger(projectID string) *Logger

NewProductionLogger returns a configured logger for production. It outputs info level and above logs with sampling. The logger is configured to output logs in the format expected by Google Cloud Logging. The projectID parameter specifies the ID of the Google Cloud project to which the logs will be sent.

func (*Logger) Debug

func (l *Logger) Debug() *Event

func (*Logger) Err

func (l *Logger) Err(err error) *Event

func (*Logger) Error

func (l *Logger) Error() *Event

func (*Logger) ErrorSpan

func (l *Logger) ErrorSpan(span trace.Span) *Event

func (*Logger) Fatal

func (l *Logger) Fatal() *Event

func (*Logger) Info

func (l *Logger) Info() *Event

func (*Logger) Log

func (l *Logger) Log() *Event

func (Logger) Output

func (l Logger) Output(w io.Writer) Logger

func (*Logger) Panic

func (l *Logger) Panic() *Event

func (*Logger) Print

func (l *Logger) Print(v ...interface{})

func (*Logger) Printf

func (l *Logger) Printf(format string, v ...interface{})

func (*Logger) Span

func (l *Logger) Span(span trace.Span) *Event

func (*Logger) Trace

func (l *Logger) Trace() *Event

func (*Logger) Warn

func (l *Logger) Warn() *Event

func (*Logger) WithLevel

func (l *Logger) WithLevel(level zerolog.Level) *Event

func (Logger) Write

func (l Logger) Write(p []byte) (n int, err error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL