MCPcopy
hub / github.com/rs/zerolog / ExampleSample

Function ExampleSample

log/log_example_test.go:237–246  ·  view source on GitHub ↗

Example of using the Sample function in the log package to set a sampler

()

Source from the content-addressed store, hash-verified

235
236// Example of using the Sample function in the log package to set a sampler
237func ExampleSample() {
238 setup()
239
240 sampled := log.Sample(&zerolog.BasicSampler{N: 2})
241 sampled.Info().Msg("hello world")
242 sampled.Info().Msg("I said, hello world")
243 sampled.Info().Msg("Can you here me now world")
244 // Output: {"level":"info","time":1199811905,"message":"hello world"}
245 // {"level":"info","time":1199811905,"message":"Can you here me now world"}
246}

Callers

nothing calls this directly

Calls 4

SampleFunction · 0.92
setupFunction · 0.85
MsgMethod · 0.80
InfoMethod · 0.65

Tested by

no test coverage detected