Skip to content

Cog provides the building blocks for creating the logging mechanism tailored to the need of your software

License

Notifications You must be signed in to change notification settings

thehungry-dev/cog

Repository files navigation

Cog

Cog provides the building blocks for creating the logging mechanism tailored to the need of your software.

Usage

package mypkg

import (
	"github.com/thehungry-dev/cog"
	"github.com/thehungry-dev/cog/handler"
	"github.com/thehungry-dev/cog/message/field"
	"github.com/thehungry-dev/cog/message/transform"
	"github.com/thehungry-dev/cog/settings"
)

var Log cog.Writer

func init() {
	set := settings.Getenv()
	device := set.Device()

  // Builds a writer that can filter log output by level, by tag and outputs colored log messages
	Log = cog.With(
		handler.BuildPipe(
			set.LevelFilter(),
			set.TagFilter(),
			handler.BuildOutput(device, handler.OutputText),
		),
	)
}
package main

func main() {
  log := mypkg.Log
  fields := field.Builder{}
  log.Info("some message")
  log.Tags("tag1", "tag2").Warn("some message")
  log.
    Tags("tag1",  "data").
    Data(
      fields.String("Name", "some name"),
      fields.Bool("SomeBool", true)
    ).
    Fatalf("Interpolated %s", "message")
}

About

Cog provides the building blocks for creating the logging mechanism tailored to the need of your software

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published