kayvee

package module
v2.4.0 Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2016 License: Apache-2.0 Imports: 4 Imported by: 3

README

kayvee

-- import "gopkg.in/Clever/kayvee-go.v2"

Package kayvee provides methods to output human and machine parseable strings, with a "json" format.

Logger API Documentation

Example

    package main

    import(
        "fmt"
        "time"

        "gopkg.in/Clever/kayvee-go.v2/logger"
    )

    func main() {
        myLogger := logger.New("myApp")

        // Simple debugging
        myLogger.Debug("Service has started")

        // Make a query and log its length
        query_start := time.Now()
        myLogger.GaugeFloat("QueryTime", time.Since(query_start).Seconds())

        // Output structured data
        myLogger.InfoD("DataResults", map[string]interface{}{"key": "value"})
    }

Testing

Run make test to execute the tests

Change log

  • v2.4 - Add kayvee-go/validator for asserting that raw log lines are in a valid kayvee format.
  • v2.3 - Expose logger.M.
  • v2.2 - Remove godeps.
  • v2.1 - Add kayvee-go/logger with log level, counters, and gauge support
  • v0.1 - Initial release.

Backward Compatibility

The kayvee 1.x interface still exist but is considered deprecated. You can find documentation on using it in the compatibility guide

Documentation

Overview

Package kayvee provides methods to output human and machine parseable strings, with a "key=val" format.

## Example

Here's an example program that outputs a kayvee formatted string:

package main

import(
  "fmt"
  "gopkg.in/Clever/kayvee.v0"
)

func main() {
  fmt.Println(kayvee.Format(map[string]interface{}{"hello": "world"}))
}

## Testing

Run `make test` to execute the tests

## Change log

v0.0.1 - Initial release.

Index

Constants

View Source
const (
	Unknown  LogLevel = "unknown"
	Critical          = "critical"
	Error             = "error"
	Warning           = "warning"
	Info              = "info"
	Trace             = "trace"
)

Constants used to define different LogLevels supported

Variables

This section is empty.

Functions

func Format

func Format(data map[string]interface{}) string

Format converts a map to a string of space-delimited key=val pairs

func FormatLog

func FormatLog(source string, level LogLevel, title string, data map[string]interface{}) string

FormatLog is similar to Format, but takes additional reserved params to promote logging best-practices

Types

type LogLevel

type LogLevel string

LogLevel denotes the level of a logging

type Logger added in v2.1.0

type Logger interface {
	Info(title string, data map[string]interface{})
	Warning(title string, data map[string]interface{})
	Error(title string, data map[string]interface{}, err error)
}

Logger is an interface satisfied by all loggers that use kayvee to Log results

type SentryLogger added in v2.1.0

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

SentryLogger provides an wrapper methods to do logging using kayvee and optionally sending errors to kayvee.

func NewSentryLogger added in v2.1.0

func NewSentryLogger(source string, logger *log.Logger, sentryClient *raven.Client) *SentryLogger

NewSentryLogger returns a new *kayvee.Logger. source is the value assigned for all logs generated by the logger log.Logger is the underlying logger used. If nil, uses log.New(os.Stderr, "", log.Ldate|log.Ltime|log.Lshortfile) sentryClient is used to optionally route errors to sentry.

func (*SentryLogger) Error added in v2.1.0

func (l *SentryLogger) Error(title string, data map[string]interface{}, err error)

Error writes a log with level kayvee.Error If the logger was initialized with a sentryClient and error is not nil, captures the error for sentry and assigns the event ID to the `sentry_event_id` key in the data.

func (*SentryLogger) Info added in v2.1.0

func (l *SentryLogger) Info(title string, data map[string]interface{})

Info writes a log with level kayvee.Info

func (*SentryLogger) Warning added in v2.1.0

func (l *SentryLogger) Warning(title string, data map[string]interface{})

Warning writes a log with level kayvee.Warning

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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