Documentation ¶
Overview ¶
Package toolbox contains various nice-to-have functions and types such as log setup, formatting and so on.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func EnvVarResolver ¶
func EnvVarResolver() kong.ResolverFunc
EnvVarResolver is an environment variable resolver for Kong -- ie it will default to the environment variable for the parameters. The parameters are named similarly to the parameter names but in upper case and with underscores. ie "--some-parameter-name" will use the environment variable "SOME_PARAMETER_NAME"
func GetSignalChannel ¶
GetSignalChannel returns the signal channel. This is for testing.
func InitLogs ¶
func InitLogs(service string, params LogParameters)
InitLogs configures logging for a service. This will turn on syslog logs if they are enabled or just a plain text stderr log. If there are any errors while running
func SendInterrupt ¶
func SendInterrupt()
SendInterrupt sends an interrupt signal to the waiting channel
func StringByteSize ¶
StringByteSize converts a size (in bytes) to bytes, kibibytes (KiB), mebibyte (MiB), gibibyte (GiB), tebibyte (TiB), pebibyte (PiB) or exbibyte (EiB) The returned string includes the unit (nnn bytes, n.nn KiB, n.nn MiB, ...)
Types ¶
type LogParameters ¶
type LogParameters struct { Level string `kong:"help='Logging level',default='debug',enum='debug,info,warning,error'"` Type string `kong:"help='Log type',default='plain',enum='syslog,plain'"` }
LogParameters contains the default log parameters