Questions tagged [logrus]
38 questions
1
vote
0 answers
logrus mqtt hook not sending logs to topic - golang
I want to use logrus hooks in golang project to send logs on MQTT topic, I have a message broker "tls://wwww-xxx.yyyyy.zzzzzzzzzzz", I'm using below code from this doc to test it with my broker, this code runs without any error and also I can see…

Shri
- 351
- 3
- 16
1
vote
0 answers
Handle Logrus and Cobra CLI in Golang
I am relatively new to the packages Cobra and Logrus in Golang and there is one little thing I would to ask for help when it comes to integrating them. I am working on a new Golang Cobra CLI which contains several commands/sub-commands. I'd like to…

crileroro
- 21
- 1
- 6
1
vote
0 answers
in golang how to store, purge and print log programatically?
I have an application with many modules and packages.
All these use logrus for logging.
Application is running in a loop. Loop after loop.
When application is has a fatal problem it prints out the log at that step. So I get the log at the error…

user1940163
- 191
- 2
- 7
1
vote
1 answer
Should logging of heavy JSON data with logrus be launched in a separate goroutine?
I need to log relatively heavy JSON data within the web request handler. Does the logrus use blocking I/O? Should I call the logger.WithFields(fields).Info(heavy_message) in a separate goroutine?

Serj Piskunov
- 33
- 5
1
vote
1 answer
Is there a way to append io.multiwriter with timestamp in go?
I am dealing with logs generated in go. Things are printed to stdout and a log file using io.multiwriterlog := io.MultiWriter(os.Stdout, logfile). I would like to add timestamps to both os.Stdout and logfile.
My approach is to write a write…
user16584124
1
vote
1 answer
Using Logs or cobra.Command Println for user feedback?
Spf13/cobra command offers a number of elegant tools to provide feedback to the user. I have more experience using Python/headless service where the standard is to use logging libraries and then redirect to stdio if necessary.
However, the more I’ve…

aronchick
- 6,786
- 9
- 48
- 75
1
vote
1 answer
Logrus hooks with syslog by demand
I'm using golang logrus for logging and I'm having a wrapper with all the regular functions like Info(..),Infof(..) e.t.c I want to implement a wrapper function Audit(..) for logging to syslog.
I noticed logrus syslog hooks problem is, once it got…

Elad Aharon
- 405
- 2
- 18
1
vote
1 answer
runtime.Callers print different program counters depending on where its run from
I have this below code that prints different program counter values depending on where its run from.
Code:
package main
import (
"fmt"
"runtime"
)
func foo() {
bar()
}
func bar() {
pcs := make([]uintptr, 10)
_ =…

Kishore Bandi
- 5,537
- 2
- 31
- 52
0
votes
1 answer
Logrus library go didn't formatted as well
I use the logrus library for my logging purposes and my expectations are like the logs in the documentation, which are like this:
And this is my log while using logrus :
I've read through the documentation and followed the code what to do, but it…

Haru-Kazumoto
- 11
- 1
0
votes
1 answer
logrus wrapper for standard go log.Logger
I have a struct requesting a standard log.Logger as parameter for log messages. From the zap logger a wrapper is provided by NewStdLogAt:
stdLogAt, err := zap.NewStdLogAt(&s.log, zap.ErrorLevel)
Now I have to use this module in a logrus logger…

k_o_
- 5,143
- 1
- 34
- 43
0
votes
0 answers
go log to file,when write get a deadlock?
my project use logrus write log to file
I use log in multi goroutine
and no other thread use the log file
but cause this deadlock:
code snippets:
writer, err := rotatelogs.New(
path.Join(opt.LogDir, opt.LogFile+".%Y-%m-%d"),
…

dtdyq
- 11
- 1
0
votes
0 answers
Golang logging JSON in CloudWatch without added Backslashes
Golang vesion: 1.18.3
Logging libs used:
"log"
"github.com/kdar/logrus-cloudwatchlogs"
"github.com/sirupsen/logrus"
I'm writing a AWS Lambda using Go. It sits behind an AWS APIGateway as a REST API.
I'm trying to log the requests got into it and the…

samme4life
- 1,143
- 2
- 14
- 20
0
votes
1 answer
Add custom field only to error logs in logrus
I'm using logrus for logging in golang. I use the following statements for logging.
logger.Info("")
logger.Errorf("Error message")
My requirement is to have a custom field (severity) only in Errorf statements with the following constraints.
If it…

Vajira Prabuddhaka
- 852
- 4
- 13
- 34
0
votes
3 answers
Use struct in place of map in logrus logging
I'm using the logrus package for logging in a Go project.
To display key value pairs in logs, the docs give the following format:
log.WithFields(log.Fields{
"animal": "walrus",
"size": 10,
}).Info("A group of walrus emerges from the…

Sagar Agarwal
- 153
- 2
- 11
0
votes
1 answer
How to store output of logrus to some variable?
This is code that converts the entered value to JSON format. It shows the correct output but I want to store that output and return it using fmt.Printf
package main
import (
log "github.com/sirupsen/logrus"
)
func main() {
…

nitin
- 11
- 1