Skip to content

Logger types reference

dmitrybond edited this page May 20, 2012 · 4 revisions

Logger types are set in the top "seelog" element. The attribute name is "type".

Synchronous

Function: Processes log message in the same goroutine where the log func was called

Type attribute value: Sync

Additional attributes: None

Example:

<seelog type="sync">
    ...
</seelog>

Asynchronous loop

Function: processes log messages in a separate goroutine. Gets messages from the message queue in a 'for' loop.

Type attribute value: asyncloop (This is the default type, so you can just omit 'type' attribute)

Additional attributes: none

Example:

<seelog type="asyncloop">
    ...
</seelog>
<seelog>
    ...
</seelog>

Asynchronous timer

Function: processes log messages in a separate goroutine. Gets messages from the message queue with a specified time interval.

Type attribute value: asynctimer

Additional attributes:

  • asyncinterval - timer interval (in nanoseconds)

Example:

<seelog type="asynctimer" asyncinterval="5000">
    ...
</seelog>

Asynchronous adaptive

Function: acts like async timer logger, but its interval depends on quantity of messages left in the queue. This type of logger is created to avoid log message queue overflow: the more messages are in the queue, the faster they are fetched. It is demonstrated in the seelog-examples:adaptive_main.go.

If we use the following notation:

  • I - interval before next item is fetched
  • m - minimal interval
  • M - maximal interval
  • c - current message count
  • C - critical message count

,then the interval formula is:

I = m + (C - Min(c, C)) / C * (M - m)

Type attribute value: adaptive

Additional attributes:

  • mininterval - minimal interval (in nanoseconds)
  • maxinterval - maximal interval (in nanoseconds)
  • critmsgcount - critical message count

Example:

<seelog type="adaptive" mininterval="2000000" maxinterval="1000000000" critmsgcount="500">
	<outputs formatid="msg">
		<console/>
	</outputs>
	<formats>
		<format id="msg" format="%Time: %Msg%n"/>
	</formats>
</seelog>