Creează un cont pentru a te abona la acest blog și a-i urmări articolele pe pagina Lectură.
-
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…
-
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.
-
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.
-
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…
-
slog.Handler is an interface type.
-
func (Attr) Equal func (a Attr) Equal(b Attr) bool Equal reports whether a and b have equal keys and values.
-
Last time we looked at slog.Group, which accepts the variadic ...any as arguments.
-
The one Attr constructor not yet covered: func Group func Group(key string, args ...any) Attr Group returns an Attr for a Group Value.
-
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.
-
We’ve already discussed when the default log/slog Logger also serves as the default log 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.
-
We’ve made it through the overview of the slog documentation.
-
One last note in the performance section… How does logging work in a concurrent system?
-
Hey everyone… I dropped the ball!
-
As I was writing yesterday’s post, a portion of the GoDoc confused me.
-
log.With isn’t the only trick available for improving performance of logging.
-
You’ve likely wondered why the log/slog package has some odd-looking functions and concepts in some places.
-
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.
-
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.
-
You may find cases where you wish to control how a value is logged, differently than how it’s used in other contexts.
-
TIL Logger.LogAttrs is a thing!
-
We’ve been talking about key/value pairs.
-
[**Idiomatic Testing in Go**](/idiomatic-testing/) starts TOMORROW!
-
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?
-
Early bird registration for [**Idiomatic Testing in Go**](/idiomatic-testing/) ends today!
-
Levels In an application, you may wish to log messages only at a certain level or greater.
-
Pop quiz.
-
I'm launching a new live course: **Idiomatic Testing in Go**.
-
I'm launching a new live course: **Idiomatic Testing in Go**.
-
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.
-
The default slog handlers are quite configurable.
-
log/slog ships with two default handlers: the TextHandler and the JSONHandler.
-
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.
-
Much like the older log package, log/slog ships with a “default logger”.
-
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.
-
Yesterday we saw that slog uses handlers to process/record logs.
-
Unlike the older log package, which provides a single *log.Logger type as its primary interface, log/slog has a two-tiered architecture.
-
I’ve been absent far too long.
-
I normally try to share Go tips and tricks, mini tutorials on this list, rather than promoting things.
-
I kinda fell off the planet for a while with family, holidays, and… writers’s block.
-
Today I want to expand with a thought I touched on yesterday: Callbacks with iterators.
-
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.
-
Yesterday we looked at a range-over-func iterator that was missing a vital piece: Error handling during iteration.
-
It’s finally time to look at how we implement a range-over-func iterator.
-
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.
-
We’ve looked at using channels as iterators, and found they’re hardly ideal.
-
I’ve been away for a while.
-
Today let’s look at re-implementing our non-iterating grep function using a channel for iteration.
-
The last few weeks I’ve been talking about different iterator patterns, but from the perspective of consuming iterators.
-
Last week I introduced the topic of range-over-func as an iterator pattern.