How can i modify custom logger wrapper to print actual error line no

With the standard/stdlib log package even if i write a wrapper i can get the actual line no using log.Output but i want to use logrus and with logrus i cannot seem a way to print the actual line. Instead logrus prints INFO[0000]logging.go:39 myfolder/logging.Info() whereas i want it to print INFO[0000]myfile.go:39 myfolder/myfile.myfunction()

This is my custom logger code, i want this to print the actual line no of the error rather than it printing this files line no.

package logging

import (

var (
	log *logrus.Logger

func init() {

	log = logrus.New()
	log.Formatter = &logrus.TextFormatter{
		CallerPrettyfier: func(f *runtime.Frame) (string, string) {
			filename := path.Base(f.File)
			return fmt.Sprintf("%s()", f.Function), fmt.Sprintf("%s:%d", filename, f.Line)
	log.Println("hello world")

// Info ...
func Info(args ...interface{}) {

// Warn ...
func Warn(args ...interface{}) {

// Error ...
func Error(args ...interface{}) {

// Fatal
func Fatal(args ...interface{}) {

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.