Documentation
¶
Overview ¶
Package channel defines the logger.
channel is using a global logger with some default parameters. It is disabled by default and the level can be increased using an environment variable:
CRY_LOG=trace CRY_LOG=info
Index ¶
- Constants
- Variables
- type Timed
- func (c *Timed[T]) Channel() chan T
- func (c *Timed[T]) Len() int
- func (c *Timed[T]) Pop() T
- func (c *Timed[T]) PopWithContext(ctx context.Context) T
- func (c *Timed[T]) PopWithTimeout(t time.Duration) T
- func (c *Timed[T]) Push(e T)
- func (c *Timed[T]) PushWithContext(ctx context.Context, e T)
- func (c *Timed[T]) PushWithTimeout(t time.Duration, e T)
Constants ¶
const EnvLogLevel = "CRY_LOG"
EnvLogLevel is the name of the environment variable to change the logging level.
Variables ¶
var BlockedPop = string("Pop blocked on channel: ")
var BlockedPush = string("Push blocked on channel: ")
var Logger = zerolog.New(logout).Level(defaultLogLevel).
With().Timestamp().Logger().
With().Str("role", "cry chan").Logger()
Logger is a globally available logger instance. By default, it only prints error level messages but it can be changed through a environment variable.
var UnblockedPop = string("Pop unblocked on channel: ")
var UnblockedPush = string("Push unblocked on channel: ")
Functions ¶
This section is empty.
Types ¶
type Timed ¶
type Timed[T any] struct { // contains filtered or unexported fields }
func WithExpiration ¶
WithExpiration creates a new channel of the given size and type
func (*Timed[T]) Pop ¶
func (c *Timed[T]) Pop() T
Pop removes an element from the channel or logs a warning if it fails after the default timeout
func (*Timed[T]) PopWithContext ¶
PopWithContext removes an element from the channel or logs a warning if it fails after the given context
func (*Timed[T]) PopWithTimeout ¶
PopWithTimeout removes an element from the channel or logs a warning if it fails after the given timeout
func (*Timed[T]) Push ¶
func (c *Timed[T]) Push(e T)
Push adds an element in the channel, or logs a warning if it fails after default timeout
func (*Timed[T]) PushWithContext ¶
PushWithContext adds an element in the channel, or logs a warning if it fails after the given context
func (*Timed[T]) PushWithTimeout ¶
PushWithTimeout adds an element in the channel, or logs a warning if it fails after the given timeout