# Functions Logger Service

## Logger Websocket endpoints 

Connector functions logger feature is available on this URL: `wss://api.opengate.es/north/functions-logger/connectorFunctions/organizations/{organization_name}/channels/{channel_name}/{cf-id}`

Rules logger feature is available on this URL: `wss://api.opengate.es/north/functions-logger/rules/organizations/{organization_name}/channels/{channel_name}/{rf-id}`

Websocket requires mandatory `X-ApiKey` url parameter to work

Another parameter to be set is logging level, used to define which traces must be sent to the client. This parameter is not mandatory and by default the INFO level will be used.

Here is a complete URI example for the connector functions logger:
```bash
wss://api.opengate.es/north/functions-logger/connectorFunctions/organizations/{organization_name}/channels/{channel_name}/{cf-id}?X-ApiKey={your-api-key}&level={logging-level}
```

Where:
* `organization_name`: Organization name.
* `channel_name`: Channel name.
* `cf-id`: Connector function identifier.
* `your-api-key`: API key of a valid user with permissions over the defined function.  
* `logging-level`: Specify logging granularity. Valid logging levels: `ERROR`, `WARN`, `INFO`, `DEBUG`, `TRACE`. If incorrect value is defined, `INFO` level will be used by Functions Logger service. Same level or higher level messages will be received. For example if `WARN` is defined in the path, `ERROR` and `WARN` traces will be received, but not `INFO`, `DEBUG` or `TRACE`.

After opening Websocket connection, the client will receive log messages with following format:
```javascript
{
    "message": "message.",
    "level": "INFO",
    "timestamp": 1607108000000
}
```

Where
- `message`: Printed trace in connector function.
- `level`: Trace level. Possible values: `ERROR`, `WARN`, `INFO`, `DEBUG`, `TRACE`. 
- `timestamp`: Trace UTC timestamp in milliseconds.