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

Error logging with Oops: \t not printed correctly #144

Open
senpro-ingwersenk opened this issue Sep 11, 2024 · 0 comments
Open

Error logging with Oops: \t not printed correctly #144

senpro-ingwersenk opened this issue Sep 11, 2024 · 0 comments

Comments

@senpro-ingwersenk
Copy link

Describe the bug
I am trying to use the oops library to do "pretty error logging", basically. The wrapped error (oops.Wrap(err)) is displayed abnormally because certain sequences (\t and \r) are not printed as expected.

Setup
Please complete the following information along with version numbers, if applicable.

  • OS Windows
  • Shell Powershell
  • Terminal Emulator Windows Terminal
  • Terminal Multiplexer None

Note: you might encounter rendering issues if your locale does not use
UTF-8 encoding. Please check your locale (locale on POSIX systems) to
see what encoding is being used by your system.

To Reproduce
Steps to reproduce the behavior:

  1. Throw an error
  2. Use oops.Wrap(err)
  3. Print the wrapped error

Source Code

	grafana := MakeGrafanaClient(
		config.Grafana.Url,
		config.Grafana.Username,
		config.Grafana.Password,
	)
	orgs, err := grafana.GetOrgs()
	if err != nil {
		err := oops.Wrap(err)
		logger.Fatal(err.Error(), "error", err)
	}
	for _, org := range orgs {
		logger.Infof("Org(%d : %s)", org.ID, org.Name)
	}

(There is another issue where my config isn't parsed correctly - but that's a different issue.)

Expected behavior
I expected to get my source fragment to be printed properly.

Screenshots
image

Additional context
oops: https://github.com/samber/oops
Viper (config loader): https://github.com/spf13/viper
Logger initialization:

// global
var logger = log.NewWithOptions(os.Stdout, log.Options{
	Prefix:       "cli",
	ReportCaller: true,
	ReportTimestamp: true,
})
var v = viper.NewWithOptions(viper.WithLogger(slog.New(logger)))
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