maskedlog

package module
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Jan 6, 2021 License: GPL-3.0 Imports: 7 Imported by: 0

README

go-maskedlog

goversion godoc Coverage reposize openissues GitHub pull requests Total alerts GitHub language count Maintenance GitHub last commit

A logger on built on top of zerolog that can mask sensitive values in the output.

Installation

go get github.com/chiselwright/go-maskedlog

Getting Started

package main

import (
	"fmt"

	"github.com/chiselwright/go-maskedlog"
)

func main() {
	logger := maskedlog.GetSingleton()

	val := "MySekritWurd"
	logger.AddSensitiveValue(val)

	logger.LogWarn(fmt.Sprintf("Failed to authenticate with password: %q", val))
}

will result in something similar to:

❯ go run .
{"level":"warn","time":"2021-01-06T21:25:19Z","message":"Failed to authenticate with password: \"MySexxxxWurd\""}

Twitter Follow

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SafeString

func SafeString(s string) string

SafeString ...

func Stringify

func Stringify(z interface{}) string

Stringify ... turns things into strings

Types

type MaskLog

type MaskLog struct {
	SensitiveStrings *MaskStrings
	Opts             interface{}
}

MaskLog is a structure to hold "useful" state

func GetSingleton

func GetSingleton() MaskLog

GetSingleton ...

func (*MaskLog) AddSensitiveValue

func (ml *MaskLog) AddSensitiveValue(s string)

AddSensitiveValue adds a new token/password value to mask in any log output

func (MaskLog) LogFatal

func (ml MaskLog) LogFatal(v ...interface{})

LogFatal does cool things

func (MaskLog) LogVerbose

func (ml MaskLog) LogVerbose(v ...interface{})

LogVerbose does other things

func (MaskLog) LogWarn

func (ml MaskLog) LogWarn(v ...interface{})

LogWarn does, uhm, warnings?

func (MaskLog) PrepareMessage

func (ml MaskLog) PrepareMessage(v interface{}) string

PrepareMessage ...

func (*MaskLog) Reset

func (ml *MaskLog) Reset()

Reset ...

func (MaskLog) SanitizeInterfaceValues

func (ml MaskLog) SanitizeInterfaceValues(z interface{})

SanitizeInterfaceValues will mask sensitive values in output

type MaskStrings

type MaskStrings []string

MaskStrings is a convenience type for the list of sensitive values to hide away

Jump to

Keyboard shortcuts

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