pine

package module
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2018 License: MIT Imports: 6 Imported by: 0

README

pine

🌲 A completely useless (but cute) logger for Golang ✨

GoDoc Codecov

Pine is a completely useless (but cute) logger for Golang. Its output may not be ideal to parse, but at least there's Emojis and color. 🙌

Installing

  1. Download and install it
$ go get -u github.com/victorgama/pine
  1. Import it in your code:
import "github.com/victorgama/pine"

Usage

Pine exports a NewWriter method that creates a new logger instance with a given module name. The logger instance has a few methods that prints data with an associated emoji. The following methods (and their emojis) are available:

Method Emoji
OK
Warn ⚠️
Issue 🐛
Error 🚨
Input 🔺
Output 🔻
Send 📤
Receive 📥
Fetch 📡
Finish 🏁
Launch 🚀
Terminate ⛔️
Spawn
Broadcast 📣
Disk 💾
Timing
Money 💰
Numbers 🔢
WTF 👻
Info 💬

For instance, the following snippet:

logger := pine.NewWriter("ModuleName")
logger.WTF("What is going %s?", "on")
logger.Numbers("Even more logging!")

Yields the following log line:

18:27:38 👻  ModuleName What is going on?
18:27:38 🔢  ModuleName Even more logging!

Every logging method has an extra method that prefixes a message with extra data:

logger.LaunchExtra("Extra Data!", "A cute formatted %s", "message")

Yielding the following line:

18:27:38 🚀  ModuleName Extra Data! A cute formatted message

As you may think, it is quite boring to repetitively include the extra parameter and keep calling LaunchWithExtra all the time. For those cases, you can call WithExtra, that attaches the provided data to the next log calls. For instance, take the following snippet:

extraLogger := logger.WithExtra("Attached data")
extraLogger.Launch("Another sweet %s", "message")
extraLogger.Finish("Process completed.")

Yielding, then, the following result:

18:27:38 🚀  ModuleName Attached data Another sweet message
18:18:38 🏁  ModuleName Attached data Process completed.

License

MIT License

Copyright (c) 2017 Victor Gama

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

Documentation

Overview

Pine is a completely useless (but cute) logging interface

Index

Constants

View Source
const (
	Error msgType = iota
	Timing
	Info
	Success
	Warn
	Spawn
	Disk
	WTF
	Finish
	Terminate
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Pine

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

Pine is a completely useless (but cute) logging interface

func (*Pine) NewWriter

func (p *Pine) NewWriter(module string) *PineWriter

NewWriter creates a new writer instance with a given module name

type PineExtraWriter

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

PineExtraWriter is a writer instance associated to a module and with a static Extra field.

func (*PineExtraWriter) Disk added in v0.2.0

func (w *PineExtraWriter) Disk(msg string, params ...interface{})

func (*PineExtraWriter) Error added in v0.2.0

func (w *PineExtraWriter) Error(msg string, params ...interface{})

func (*PineExtraWriter) Finish added in v0.2.0

func (w *PineExtraWriter) Finish(msg string, params ...interface{})

func (*PineExtraWriter) Info added in v0.2.0

func (w *PineExtraWriter) Info(msg string, params ...interface{})

func (*PineExtraWriter) Spawn added in v0.2.0

func (w *PineExtraWriter) Spawn(msg string, params ...interface{})

func (*PineExtraWriter) Success added in v0.2.0

func (w *PineExtraWriter) Success(msg string, params ...interface{})

func (*PineExtraWriter) Terminate added in v0.2.0

func (w *PineExtraWriter) Terminate(msg string, params ...interface{})

func (*PineExtraWriter) Timing added in v0.2.0

func (w *PineExtraWriter) Timing(msg string, params ...interface{})

func (*PineExtraWriter) WTF added in v0.2.0

func (w *PineExtraWriter) WTF(msg string, params ...interface{})

func (*PineExtraWriter) Warn added in v0.2.0

func (w *PineExtraWriter) Warn(msg string, params ...interface{})

type PineWriter

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

PineWriter is a writter instance already associated to a module.

func NewWriter

func NewWriter(module string) *PineWriter

NewWriter creates a new Writer instance using the provided module name

func (*PineWriter) Disk added in v0.2.0

func (w *PineWriter) Disk(msg string, params ...interface{})

func (*PineWriter) DiskExtra added in v0.2.0

func (w *PineWriter) DiskExtra(extra, msg string, params ...interface{})

func (*PineWriter) Error added in v0.2.0

func (w *PineWriter) Error(msg string, params ...interface{})

func (*PineWriter) ErrorExtra added in v0.2.0

func (w *PineWriter) ErrorExtra(extra, msg string, params ...interface{})

func (*PineWriter) Finish added in v0.2.0

func (w *PineWriter) Finish(msg string, params ...interface{})

func (*PineWriter) FinishExtra added in v0.2.0

func (w *PineWriter) FinishExtra(extra, msg string, params ...interface{})

func (*PineWriter) Info added in v0.2.0

func (w *PineWriter) Info(msg string, params ...interface{})

func (*PineWriter) InfoExtra added in v0.2.0

func (w *PineWriter) InfoExtra(extra, msg string, params ...interface{})

func (*PineWriter) Spawn added in v0.2.0

func (w *PineWriter) Spawn(msg string, params ...interface{})

func (*PineWriter) SpawnExtra added in v0.2.0

func (w *PineWriter) SpawnExtra(extra, msg string, params ...interface{})

func (*PineWriter) Success added in v0.2.0

func (w *PineWriter) Success(msg string, params ...interface{})

func (*PineWriter) SuccessExtra added in v0.2.0

func (w *PineWriter) SuccessExtra(extra, msg string, params ...interface{})

func (*PineWriter) Terminate added in v0.2.0

func (w *PineWriter) Terminate(msg string, params ...interface{})

func (*PineWriter) TerminateExtra added in v0.2.0

func (w *PineWriter) TerminateExtra(extra, msg string, params ...interface{})

func (*PineWriter) Timing added in v0.2.0

func (w *PineWriter) Timing(msg string, params ...interface{})

func (*PineWriter) TimingExtra added in v0.2.0

func (w *PineWriter) TimingExtra(extra, msg string, params ...interface{})

func (*PineWriter) WTF added in v0.2.0

func (w *PineWriter) WTF(msg string, params ...interface{})

func (*PineWriter) WTFExtra added in v0.2.0

func (w *PineWriter) WTFExtra(extra, msg string, params ...interface{})

func (*PineWriter) Warn added in v0.2.0

func (w *PineWriter) Warn(msg string, params ...interface{})

func (*PineWriter) WarnExtra added in v0.2.0

func (w *PineWriter) WarnExtra(extra, msg string, params ...interface{})

func (*PineWriter) WithExtra

func (p *PineWriter) WithExtra(extra string) *PineExtraWriter

WithExtra returns a new PineExtraWriter with an associated module and static extra value

type Writer added in v0.2.0

type Writer interface {
	Info(msg string, params ...interface{})
	Success(msg string, params ...interface{})
	Warn(msg string, params ...interface{})
	Error(msg string, params ...interface{})
	Timing(msg string, params ...interface{})
	WTF(msg string, params ...interface{})
	Finish(msg string, params ...interface{})
	Terminate(msg string, params ...interface{})
	Spawn(msg string, params ...interface{})
	Disk(msg string, params ...interface{})
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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