gopherlogs icon indicating copy to clipboard operation
gopherlogs copied to clipboard

Weird precent sign at end of logging `%`

Open jpmcb opened this issue 1 year ago • 0 comments

At the end of logging, we get a weird percent sign. This is likely due to some of the line trimming that happens.

here's the example go program:

func main() {
        l, err := gopherlogs.NewLogger(
        gopherlogs.WithLogLevel(0),
    )
    if err != nil {
        panic("New logger could not be created!")
    }

        l.Event(emojis.WrenchEmoji, " Starting application")

        // start a go routine with some animated logs
        ctx, cancel := context.WithCancel(context.Background())
        go func(ctx context.Context) {
                l.Style(3, colors.FgYellow).AnimateProgressWithOptions(
                        gopherlogs.AnimatorWithContext(ctx),
                        gopherlogs.AnimatorWithMaxLen(3),
            gopherlogs.AnimatorWithMessagef("abcdefghijklmnopqrstuvwxyz0123456789: %s", "test line 1"),
                )
        }(ctx)

        // Do some "work" in this thread and cancel the context once it's done.
        time.Sleep(time.Second * 3)
        cancel()
        l.Style(3, colors.FgGreen).ReplaceLinef("Stuff is all done!")

        // start a go routine with some animated logs
        ctx, cancel = context.WithCancel(context.Background())
        go func(ctx context.Context) {
                l.Style(3, colors.FgYellow).AnimateProgressWithOptions(
                        gopherlogs.AnimatorWithContext(ctx),
                        gopherlogs.AnimatorWithMaxLen(3),
            gopherlogs.AnimatorWithMessagef("abcdefghijklmnopqrstuvwxyz0123456789: %s", "test line 2"),
                )
        }(ctx)

        // Do some "work" in this thread and cancel the context once it's done.
        time.Sleep(time.Second * 3)
        cancel()
        l.Style(3, colors.FgGreen).ReplaceLinef("More stuff is all done!")

        l.Style(0, colors.FgCyan).Eventf(emojis.GreenCheckEmoji, " All done! Thanks for using gopherlogs!!")
}

And here's the output:

❯ go run main.go

🔧  Starting application
   Stuff is all done!
   More stuff is all done!

✅  All done! Thanks for using gopherlogs!!%

Notice the % at the end of the logging there

jpmcb avatar May 05 '23 04:05 jpmcb