Discussion
Loading...

Post

  • About
  • Code of conduct
  • Privacy
  • Users
  • Instances
  • About Bonfire
Miek Gieben
@miek@mastodon.cloud  ·  activity timestamp last week

hmmm. Putting a slog in http.Server's ErrorLog is easy, but the output is not what I want.
I *just* want slog.Error to be used, but the TextHandler makes everything structured #golang

  • Copy link
  • Flag this post
  • Block
Miek Gieben
@miek@mastodon.cloud replied  ·  activity timestamp last week

looks like this is the incantation

logger := slog.NewLogLogger(slog.Default().Handler(), slog.LevelError)

  • Copy link
  • Flag this comment
  • Block
Maybe(oz)
@oz@mastodon.social replied  ·  activity timestamp last week

@miek if you want unstructured text logs, slog is not the best tool. It will try to make key-value with everything.

  • Copy link
  • Flag this comment
  • Block
Miek Gieben
@miek@mastodon.cloud replied  ·  activity timestamp last week

@oz but, not the default output:

2025/10/02 15:30:44 INFO Startup functions total=5

  • Copy link
  • Flag this comment
  • Block
Maybe(oz)
@oz@mastodon.social replied  ·  activity timestamp last week

@miek Oh, I think I get it. Let me know if you figure it out. :)

  • Copy link
  • Flag this comment
  • Block
Miek Gieben
@miek@mastodon.cloud replied  ·  activity timestamp last week

@oz logger := slog.NewLogLogger(slog.Default().Handler(), slog.LevelError)

  • Copy link
  • Flag this comment
  • Block
Log in

bonfire.cafe

A space for Bonfire maintainers and contributors to communicate

bonfire.cafe: About · Code of conduct · Privacy · Users · Instances
Bonfire social · 1.0.0-rc.3.13 no JS en
Automatic federation enabled
  • Explore
  • About
  • Members
  • Code of Conduct
Home
Login