View definition

func RegisterCustomFormatter

Defined in


RegisterCustomFormatter registers a new custom formatter factory with a given name. If returned error is nil, then this name (prepended by '%' symbol) can be used in 'format' attributes in configuration and it will be treated like the standard parameterized formatter identifiers.

RegisterCustomFormatter needs to be called before creating a logger for it to take effect. The general recommendation is to call it once in 'init' func of your application or any initializer func.

For usage examples, check

Name must only consist of letters (unicode.IsLetter).

Name must not be one of the already registered standard formatter names ( and previously registered custom format names. To avoid any potential name conflicts (in future releases), it is recommended to start your custom formatter name with a namespace (e.g. 'MyCompanySomething') or a 'Custom' keyword.

RegisterCustomFormatter is referenced in 2 repositories