CustomReceiver is the interface that external custom seelog message receivers must implement in order to be able to process seelog messages. Those receivers are set in the xml config file using the <custom> tag. Check receivers reference wiki section on that.

Use seelog.RegisterReceiver on the receiver type before using it.

CustomReceiver is referenced in 1 repository


type CustomReceiver interface {
	// ReceiveMessage is called when the custom receiver gets seelog message from
	// a parent dispatcher.
	// Message, level and context args represent all data that was included in the seelog
	// message at the time it was logged.
	// The formatting is already applied to the message and depends on the config
	// like with any other receiver.
	// If you would like to inform seelog of an error that happened during the handling of
	// the message, return a non-nil error. This way you'll end up seeing your error like
	// any other internal seelog error.
	ReceiveMessage(message string, level LogLevel, context LogContextInterface) error

	// AfterParse is called immediately after your custom receiver is instantiated by
	// the xml config parser. So, if you need to do any startup logic after config parsing,
	// like opening file or allocating any resources after the receiver is instantiated, do it here.
	// If this func returns a non-nil error, then the loading procedure will fail. E.g.
	// if you are loading a seelog xml config, the parser would not finish the loading
	// procedure and inform about an error like with any other config error.
	// If your custom logger needs some configuration, you can use custom attributes in
	// your config. Check CustomReceiverInitArgs.XmlCustomAttrs comments.
	// IMPORTANT: This func is NOT called when the LoggerFromCustomReceiver func is used
	// to create seelog proxy logger using the custom receiver. This func is only called when
	// receiver is instantiated from a config.
	AfterParse(initArgs CustomReceiverInitArgs) error

	// Flush is called when the custom receiver gets a 'flush' directive from a
	// parent receiver. If custom receiver implements some kind of buffering or
	// queing, then the appropriate reaction on a flush message is synchronous
	// flushing of all those queues/buffers. If custom receiver doesn't have
	// such mechanisms, then flush implementation may be left empty.

	// Close is called when the custom receiver gets a 'close' directive from a
	// parent receiver. This happens when a top-level seelog dispatcher is sending
	// 'close' to all child nodes and it means that current seelog logger is being closed.
	// If you need to do any cleanup after your custom receiver is done, you should do
	// it here.
	Close() error