mirror of
https://github.com/fnproject/fn.git
synced 2022-10-28 21:29:17 +03:00
Configure logrus to include nano seconds in log messages (#1273)
Currently the default time format, time.RFC3339, is used, which doesn't include any subsecond resolution information. This makes it hard to understand the ordering of log messages when viewing in a log aggregator, like Kibana. This change sets the TimestampFormat of the logrus JSONFormatter to time.RFC3339Nano.
This commit is contained in:
@@ -3,10 +3,11 @@ package common
|
|||||||
import (
|
import (
|
||||||
"net/url"
|
"net/url"
|
||||||
"os"
|
"os"
|
||||||
|
"strings"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
"strings"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func SetLogFormat(format string) {
|
func SetLogFormat(format string) {
|
||||||
@@ -15,7 +16,7 @@ func SetLogFormat(format string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if format == "json" {
|
if format == "json" {
|
||||||
logrus.SetFormatter(&logrus.JSONFormatter{})
|
logrus.SetFormatter(&logrus.JSONFormatter{TimestampFormat: time.RFC3339Nano})
|
||||||
} else {
|
} else {
|
||||||
// show full timestamps
|
// show full timestamps
|
||||||
formatter := &logrus.TextFormatter{
|
formatter := &logrus.TextFormatter{
|
||||||
|
|||||||
Reference in New Issue
Block a user