glog

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2023 License: Apache-2.0 Imports: 3 Imported by: 0

README

The glog Backend for Deck

The glog backend is based on Google's github.com/golang/glog logging package.

The logger backend supports all platforms.

Init

The glog backend takes a single setup parameter, opts.

The opts parameter allows the caller to supply a glog.Options struct to customize the backend behavior.

Attributes

GlogV

The underlying glog package implements its own verbosity levels which are independent of deck and controlled via separate, self-defined flags. The GlogV attribute allows the caller to pass V() directly to the glog package without invoking Deck's own verbosity handling (which affects all backends).

deck.Depth

The glog package will attempt to make use of deck's core Depth attribute. This allows the caller to modify the call depth, which may affect the file names and line numbers rendered on the output. If Depth isn't specified, glog tries to do the right thing and set depth to the original call site.

Usage

import (
  github.com/google/deck
  github.com/google/deck/backends/glog
)

...
func main() {
  deck.Add(glog.Init(nil))
}

Documentation

Overview

Package glog provides a deck backend for github.com/golang/glog.

The glog backend supports two types of logging to the glog package. The first is to use deck's standard level functions .Info(), .Error(), etc. These map to the same function calls inside glog.

We also support glog's V-style logging by exporting a V() attribute. This attribute is separate from deck's core V() attribute and only affects glog. When a glog.V() attribute is applied, the V level is passed to glog's V-style info functions.

Example:

deck.InfoA("a message at level 3").With(glog.V(3)).Go()

Providing the V() attribute overrides the deck level, so this:

deck.ErrorA("a message with verbosity").With(glog.V(3)).Go()

is the same as this:

deck.InfoA("a message with verbosity").With(glog.V(3)).Go()

The glog backend will also attempt to honor deck's Depth() attribute, allowing the caller to modify the stack frames output by glog messages.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func V

func V(level log.Level) func(*deck.AttribStore)

V is an attribute that allows use of glog's V-style logging.

This is different from deck's V() attribute, which affects the behavior of all backends! glog.V() only modifies the behavior of glog.

Types

type GLog

type GLog struct {
	// contains filtered or unexported fields
}

GLog is a log deck backend that passes logs through to the glog package.

func Init

func Init(opts *Options) *GLog

Init initializes the glog backend for use in a deck.

func (*GLog) Close

func (g *GLog) Close() error

Close closes the glog backend.

func (*GLog) New

func (g *GLog) New(lvl deck.Level, msg string) deck.Composer

New creates a new GLog message.

type Options

type Options struct {
	// DebugLevel indicates the V() to use for deck Debug messages. Defaults to 1.
	DebugLevel log.Level
}

Options allows the caller to customize the behavior of the glog backend.

Jump to

Keyboard shortcuts

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