https://github.com/aphistic/gomol-console
A gomol logger to write to the console.
https://github.com/aphistic/gomol-console
gomol
Last synced: 5 months ago
JSON representation
A gomol logger to write to the console.
- Host: GitHub
- URL: https://github.com/aphistic/gomol-console
- Owner: aphistic
- License: mit
- Created: 2016-07-12T14:30:54.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2018-01-11T15:22:29.000Z (almost 8 years ago)
- Last Synced: 2025-06-22T13:06:31.518Z (5 months ago)
- Topics: gomol
- Language: Go
- Size: 12.7 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
gomol-console
============
[](https://godoc.org/github.com/aphistic/gomol-console)
[](https://travis-ci.org/aphistic/gomol-console)
[](http://codecov.io/github/aphistic/gomol-console?branch=master)
gomol-console is a logger for [gomol](https://github.com/aphistic/gomol) to support logging to the console.
Installation
============
The recommended way to install is via http://gopkg.in
go get gopkg.in/aphistic/gomol-console.v0
...
import "gopkg.in/aphistic/gomol-console.v0"
gomol-console can also be installed the standard way as well
go get github.com/aphistic/gomol-console
...
import "github.com/aphistic/gomol-console"
Examples
========
For brevity a lot of error checking has been omitted, be sure you do your checks!
This is a super basic example of adding a console logger to gomol and then logging a few messages:
```go
package main
import (
"github.com/aphistic/gomol"
gc "github.com/aphistic/gomol-console"
)
func main() {
// Add an io.Writer logger
consoleCfg := gc.NewConsoleLoggerConfig()
consoleLogger, _ := gc.NewConsoleLogger(consoleCfg)
gomol.AddLogger(consoleLogger)
// Set some global attrs that will be added to all
// messages automatically
gomol.SetAttr("facility", "gomol.example")
gomol.SetAttr("another_attr", 1234)
// Initialize the loggers
gomol.InitLoggers()
defer gomol.ShutdownLoggers()
// Log some debug messages with message-level attrs
// that will be sent only with that message
for idx := 1; idx <= 10; idx++ {
gomol.Dbgm(
gomol.NewAttrs().
SetAttr("msg_attr1", 4321),
"Test message %v", idx)
}
}
```