🌲 A completely useless (but cute) logger for Golang ✨
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
generators
.gitignore
.travis.yml
LICENSE
README.md
pine.go
types.json

README.md

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.