# startup

## Summary

**optional** `function startup(logger)`

| **Parameters** | Description          |
| -------------- | -------------------- |
| logger         | bunyan logger object |

The startup method is called once when the integration is first started (or restarted). It should be used to perform any initialization logic that your integration requires. In addition, the `startup` method is passed a Bunyan logger object which you can cache for later use.

{% hint style="info" %}
Bunyan is an open source JSON logging library.  You can find more information here <https://github.com/trentm/node-bunyan>
{% endhint %}

## Parameters

### logger

Once you have cached the `Logger` object you can use it to log information to the integration log file. The simplest usage of the Logger is to log `string` messages using one of the six provided logging levels.

```javascript
Logger.trace("This is a trace message");
Logger.debug("This is a debug message");
Logger.info("This is an info message");
Logger.warn("This is a warning message");
Logger.error("This is an error message");
Logger.fatal("This is a fatal message");
```

You can also pass object literals to be converted into JSON and logged. If you are returning a single object you can pass that as the first parameter to any of the `Logger` methods.

```javascript
Logger.info(entity, "An entity was looked up");
Logger.fatal(error, "There was a fatal error in the doLookup method");
```

If you want to return multiple objects or properties you can do that as well.

```javascript
Logger.error({err: err, entity: entity}, "There was an error in the doLookup method");
```

## Examples

The following example show how you can cache the logger object within the startup method for use elsewhere in the `integration.js` file.

{% code title="integration.js" %}

```javascript
// declare a global Logger variable
let Logger;

function startup(logger){
    Logger = logger;
    Logger.info("Startup Method Called");
}

function doLookup(entities, options, cb){
    Logger.info({entities, options}, "doLookup was called!");
    cb(null, []);
}

module.exports = {
    startup: startup
}
```

{% endcode %}

### &#x20;<a href="#validateoptions" id="validateoptions"></a>
