Example of using the Sample function in the log package to set a sampler
()
| 235 | |
| 236 | // Example of using the Sample function in the log package to set a sampler |
| 237 | func 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 | } |