← Înapoi la Urmăritori

Cel mai recent articol

Ultima verificare

Urmăritori 0 urmăritori
Articole: 200
  1. slog.Handler

    I’m probably doing this in backwards order, but that’s the order the GoDoc presents it… Now that we’ve looked at each of the methods of the Handler interface, we come to its general description: type Handler A Handler handles log records produced by a Log…

  2. I hope everyone had a good Labor Day weekend… even if you’re not in the US and had to/got to labor on Monday.

  3. type Handler type Handler interface { … // WithAttrs returns a new Handler whose attributes consist of // both the receiver's attributes and the arguments. // The Handler owns the slice: it may retain, modify or discard it.

  4. slog.Handler.Handle()

    I had not intended to take a month off, but then GopherCon came, and life happened… but now I’m back, and ready to rock and roll again… Today we’re to the core of the Handler interface: the Handle method. type Handler type Handler interface { … // Handle…

  5. slog Handler methods

    slog.Handler is an interface type.

  6. Attribute equality

    func (Attr) Equal func (a Attr) Equal(b Attr) bool Equal reports whether a and b have equal keys and values.

  7. slog.GroupAttrs

    Last time we looked at slog.Group, which accepts the variadic ...any as arguments.

  8. slog.Group

    The one Attr constructor not yet covered: func Group func Group(key string, args ...any) Attr Group returns an Attr for a Group Value.

  9. The Attr type

    Other than logger methods, the slog.Attr type is probably the thing you’ll use the most in your use of the slog package: Types type Attr type Attr struct { Key string Value Value } An Attr is a key-value pair.

  10. We’ve already discussed when the default log/slog Logger also serves as the default log Logger.

  11. The global logger

    I’m going to do something I haven’t done before in these stdlib tours, and that is skip over a huge section of the GoDoc.

  12. slog Constants

    We’ve made it through the overview of the slog documentation.

  13. Concurrent logging

    One last note in the performance section… How does logging work in a concurrent system?

  14. Hey everyone… I dropped the ball!

  15. As I was writing yesterday’s post, a portion of the GoDoc confused me.

  16. Attribute evaluation

    log.With isn’t the only trick available for improving performance of logging.

  17. You’ve likely wondered why the log/slog package has some odd-looking functions and concepts in some places.

  18. Working with Records

    In my experience, it’s rare you’ll need to worry about slog Records, unless you’re writing a Handler, or some kind of middleware/transform.

  19. Let’s talk about a feature I’ve never used, or even knew existed… I mentioned a while back that the AddSource field of HandlerOptions controls whether the log output includes the source code position of the log call.

  20. You may find cases where you wish to control how a value is logged, differently than how it’s used in other contexts.

  21. Values

    TIL Logger.LogAttrs is a thing!

  22. Attrs

    We’ve been talking about key/value pairs.

  23. Contexts

    [**Idiomatic Testing in Go**](/idiomatic-testing/) starts TOMORROW!

  24. More with Groups

    Organizing log key/value pairs by group is a nice way to organize your logging data, but what about organizing the way your application groups data?

  25. Groups

    Early bird registration for [**Idiomatic Testing in Go**](/idiomatic-testing/) ends today!

  26. Levels In an application, you may wish to log messages only at a certain level or greater.

  27. Pop quiz.

  28. I'm launching a new live course: **Idiomatic Testing in Go**.

  29. Log levels

    I'm launching a new live course: **Idiomatic Testing in Go**.

  30. Logging common fields

    It’s common that you’ll want to include certain attributes in all logs in an application or component. log/slog makes this pretty easy.

  31. Handler configuration

    The default slog handlers are quite configurable.

  32. log/slog ships with two default handlers: the TextHandler and the JSONHandler.

  33. Today I’m going to jump around a bit in the GoDoc, to talk about a topic I mentioned last time: how to override the default logger.

  34. The default handler

    Much like the older log package, log/slog ships with a “default logger”.

  35. Intro to slog levels

    By default, the log/slog package supports four log levels: Debug, Info, Warn, and Error, each of which has matching logger methods: Overview … The Info top-level function calls the Logger.Info method on the default Logger.

  36. Yesterday we saw that slog uses handlers to process/record logs.

  37. Unlike the older log package, which provides a single *log.Logger type as its primary interface, log/slog has a two-tiered architecture.

  38. I’ve been absent far too long.

  39. I normally try to share Go tips and tricks, mini tutorials on this list, rather than promoting things.

  40. Happy late new year

    I kinda fell off the planet for a while with family, holidays, and… writers’s block.

  41. Iterator callbacks

    Today I want to expand with a thought I touched on yesterday: Callbacks with iterators.

  42. Last time we modified our range-over-func iterator to return a iter.Seq2, so that it could include a possible error value for each iteration.

  43. Yesterday we looked at a range-over-func iterator that was missing a vital piece: Error handling during iteration.

  44. It’s finally time to look at how we implement a range-over-func iterator.

  45. Last week we looked at a simple custom iterator pattern: type Result struct {/* ... */} func (*Result) Next() (string, bool) func (*Result) Err() error But let’s talk about a few variations, and when they might make sense.

  46. We’ve looked at using channels as iterators, and found they’re hardly ideal.

  47. I’ve been away for a while.

  48. Today let’s look at re-implementing our non-iterating grep function using a channel for iteration.

  49. The last few weeks I’ve been talking about different iterator patterns, but from the perspective of consuming iterators.

  50. Last week I introduced the topic of range-over-func as an iterator pattern.