snorkel

package module
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Sep 19, 2024 License: MIT Imports: 6 Imported by: 11

README

snorkel

Logo

GoDoc Go

Scuba for the rest of us.

go get maragu.dev/snorkel

Made in 🇩🇰 by maragu, maker of online Go courses.

Features

  • Simple logger with just a single method, Event, which logs named events with a given sample rate.
  • Sane defaults log to STD_ERR and include event name, sample rate, time, and build info. More to come.
  • No external dependencies.

Usage

package main

import (
	"maragu.dev/snorkel"
)

func main() {
	log := snorkel.New(snorkel.Options{})

	// Log an event with the name "Yo", sample rate 1, and env=sparkly
	log.Event("Yo", 1, "env", "sparkly")
}

Documentation

Overview

Package snorkel provides a Logger which logs wide events in JSON format.

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Logger

type Logger struct {
	// contains filtered or unexported fields
}
Example
package main

import (
	"maragu.dev/snorkel"
)

func main() {
	log := snorkel.New(snorkel.Options{})
	log.Event("Yo", 1, "env", "sparkly")
}
Output:

func New

func New(opts Options) *Logger

New Logger with the given Options.

func NewDiscard added in v0.4.1

func NewDiscard() *Logger

func (*Logger) Event

func (l *Logger) Event(name string, rate float32, args ...any)

Event to log with the given name, sample rate, and arguments.

type Options

type Options struct {
	NoTime       bool
	RandomSource rand.Source
	W            io.Writer
}

Jump to

Keyboard shortcuts

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