Skip to content
This repository has been archived by the owner on May 23, 2023. It is now read-only.

clarify LazyLogger semantics #118

Open
RaduBerinde opened this issue Sep 28, 2016 · 1 comment
Open

clarify LazyLogger semantics #118

RaduBerinde opened this issue Sep 28, 2016 · 1 comment

Comments

@RaduBerinde
Copy link
Contributor

There are some questions around LazyLogger that should be clarified in the comments:

  • what is the purpose of Encoder.EmitLazyLogger (as opposed to just calling the LazyLogger directly); some motivation described in the discussion here: Add convenience methods Key() and Value() to log.Field #116 (comment)
  • can a LazyLogger call Emit* functions more than once?
  • If yes, can each of those calls provide different keys?
  • If no (to either of the above), is it intentional that we don't know the key of the field (without calling the LazyLogger)?
  • Is it ok to call the LazyLogger if we just need the key (e.g. for Field.Key()?)
@yurishkuro
Copy link
Member

can a LazyLogger call Emit* functions more than once?

imo - yes

If yes, can each of those calls provide different keys?

yes, but a better question - can it provide the SAME keys? We have not specified a map or multi-map semantics for KV logging fields. I usually prefer multi-map, since the actual storage is just a list of k/v.

is it intentional that we don't know the key of the field

yes, it is intentional. The key of the lazy logger is meaningless since the logger itself does not have access to it when executed, yet it needs to provide the keys when calling methods on the Encoder.

Is it ok to call the LazyLogger if we just need the key (e.g. for Field.Key()?)

it will return empty string

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

No branches or pull requests

2 participants