Skip to content
Snippets Groups Projects
Commit a387d75a authored by Ankur Mittal's avatar Ankur Mittal
Browse files

[golang-syslog] Add documentation.

US-426 #progress

Change-Id: I30294414a62bd0633320832f9bca1be2cddbed07
parent 9a72fb95
No related branches found
No related tags found
No related merge requests found
# Syslog
This document explains how to use golang syslogger library.
## gn dependency
```
extra_dependencies = [
"//garnet/public/lib/syslog/go/src/syslog",
"//garnet/public/lib/app/go/src/app",
]
```
### Initialization
Logger can only be initialized once.
#### Basic initialization
```golang
import (
"app/context"
"syslog/logger"
)
func main() {
ctx := context.CreateFromStartupInfo()
err := logger.InitDefaultLogger(ctx.GetConnector())
}
```
#### Initialization with tags
```golang
import (
"app/context"
"syslog/logger"
)
func main() {
ctx := context.CreateFromStartupInfo()
// Global tags, max 4 tags can be passed. Every log message would be tagged using these.
err := logger.InitDefaultLoggerWithTags(ctx.GetConnector(), tag1, tag2)
}
```
### Log messages
```golang
logger.Infof("my msg: %d", 10);
// Allow message specific tagging. This message is going to be tagged with
// this local tag and any global tag passed during initialization.
logger.InfoTf("tag", "my msg: %d", 10);
logger.Warnf("my msg: %d", 10);
logger.WarnTf("tag", "my msg: %d", 10);
logger.Errorf("my msg: %d", 10);
logger.ErrorTf("tag", "my msg: %d", 10);
logger.Fatalf("my msg: %d", 10);
logger.FatalTf("tag", "my msg: %d", 10);
logger.VLogf(1, "my msg: %d", 10); // verbose logs
logger.VLogTf(1, "tag", "my msg: %d", 10); // verbose logs
```
### Reference
[Golang APIs](https://fuchsia.googlesource.com/garnet/+/master/public/lib/syslog/go/src/syslog/logger/logger.go)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment