# eva_log

### MODULE

eva_log

### MODULE SUMMARY

Log functionality for events and alarms in EVA

### DESCRIPTION

The EVA log service uses the generic Log Control service to implement log functionality for events and alarms defined in EVA.

In the rest of this description, the term event refers to both events and alarms as defined in EVA.

This log functionality supports logging of events from EVA. It uses the module `disk_log` for logging of events, using the internal log format defined by `disk_log`. There can be several logs active at the same time. Each log uses a filter function to decide whether an event should be stored in the log or not.

There are several ways to control whether an event should be stored in a log or not. First of all, `eva_log` checks if the `log` flag in `eventTable` is set (see `eva(3)`). If it is set to `false`, the event is not stored in any log, even if there are logs that are configured to log the event. In this way, logging of individual events can be turned on/off by a manager. If the `log` flag is `true`, `eva_log` checks the operational status of the log. If it is `down`, the event is not stored. If it is `up`, the associated filter function is called. If this function returns `true`, the event is stored, otherwise it is discarded. To summarize, all these conditions must be true for an event to be stored:

- The `log` flag for the event is `true`.
- The operational status for the log is `up`.
- The filter function for the log returns `true`, when applied to the event.

There is a concept of a default log. The default log is used to log any event that has the `log` flag in `eventTable` set to `true`, but no log is currently able to store the event (or there is no other log defined to log the event). The usage of the default log is optional.

### EXPORTS

`close(Name) -> ok`

Types:

`Name = string()`

Closes an event log.

`get_logs() -> [#eva_log]`

Returns all event logs known to `eva_log`. The record `#eva_log` is defined in the file `eva_log.hrl`.

`open(Name, FilterFunction, WrapTime) -> ok | {error, Reason}`

Types:

`Name = string()`
`FilterFunction = {M, F, A}`
`M = F = atom()`
`A = list()`
`WrapTime = integer()`

Makes `eva_log` aware of the log `Name`. The log must be an open `disk_log` log, with log format `internal`. This function will call `log:open(Name, eva_log, WrapTime)` in order to register the log in the generic Log Control service.

The `FilterFunction` is used when an event is received from EVA. It is then called as `M:F(Event ++ A)`, and supposed to return `true` if the event should be stored in the log. All other return values makes the event be discarded. The filter function can be exchanged during runtime, by using `set_filter/2`.

`set_filter(Name, FilterFunction)`

Types:

`Name = string()`
`FilterFunction = {M, F, A}`
`M = F = atom()`
`A = list()`

Changes the filter function for the event log.

`start_link()`
`start_link(DefaultLog) -> {ok, Pid} | {error, Reason}`

Types:

`DefaultLog = {Name, WrapTime} | false`
`Name = string()`
`WrapTime = integer()`

Starts the eva log service. This function can be used to include the service in a supervisor. Normally, functions in the supervisor `eva_sup` can be used instead.

`DefaultLog` is either the name and wrap time of the default log to use, or `false`. If it is not `false`, the log must have been created with `disk_log`, just as any other log (see `open/3`). The default log is used to log any event that has the `log` flag set to true in `eventTable`, but no log has actually logged the event, either because there was no such log, or the log had operational status `down`. If the `DefaultLog` argument is omitted, it defaults to `false`. If the default log is used, it will be made known to the generic Log Control service as `log:open(Name, eva_log, WrapTime)`.

### See Also

disk_log(3), eva(3), eva_sup(3), file(3), log(3)

### AUTHORS

Martin Björklund - support@erlang.ericsson.se

eva 2.0.4
Copyright © 1991-2003 Ericsson Utvecklings AB