Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Weird precent sign at end of logging % #4

Open
jpmcb opened this issue May 5, 2023 · 0 comments
Open

Weird precent sign at end of logging % #4

jpmcb opened this issue May 5, 2023 · 0 comments

Comments

@jpmcb
Copy link
Owner

jpmcb commented May 5, 2023

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant