logger

package module
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: May 28, 2020 License: GPL-3.0 Imports: 7 Imported by: 0

README

maclir/function-logger

A wrapper to contain bioler plate code for logging on google cloud functions.

Installations

go get -u github.com/maclir/function-logger

Usage

package something

import (
...
	"cloud.google.com/go/logging"
	flogger "github.com/maclir/function-logger"
)

// reused between function invocations.
var logger *logging.Logger

func init() {
	var err error
	logger, err = flogger.New()
	if err != nil {
		panic(err)
	}
}

func Something(w http.ResponseWriter, r *http.Request) {
	defer logger.Flush()

	...

	logger.Log(logging.Info, "This is a log")

	...
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Logger added in v1.1.0

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

func New

func New() (*Logger, error)

New creates wraps a new instance of logging.Logger with function attributes.

func (*Logger) Flush added in v1.1.0

func (l *Logger) Flush()

Flush is a wrapper for logging.Flush.

func (*Logger) Log added in v1.1.0

func (l *Logger) Log(s logging.Severity, payload interface{})

Log is a wrapper for logging.Log which takes Severity and payload to pass on.

Jump to

Keyboard shortcuts

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