Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/elmahio/elmah.io.javascript

elmah.io javascript logger.
https://github.com/elmahio/elmah.io.javascript

crash-reporting crash-reporting-tool elmah elmah-io error-handling error-log error-monitoring error-reporting javascript javascript-logger logger logging

Last synced: about 2 months ago
JSON representation

elmah.io javascript logger.

Awesome Lists containing this project

README

        

# elmah.io.javascript
![license](https://img.shields.io/hexpm/l/plug.svg?style=flat-square)

Log to [elmah.io](https://elmah.io) from JavaScript. For the most recent documentation, visit [Logging to elmah.io from JavaScript](https://docs.elmah.io/logging-to-elmah-io-from-javascript/).

### Initialization

Immediately-Invoked Function Expression (IIFE)
```html

```

UMD Constructor with options
```html

var log = new Elmahio({
apiKey: 'YOUR-API-KEY',
logId: 'YOUR-LOG-ID',
});

```

### Default options
```javascript
new Elmahio({
apiKey: null,
logId: null,
debug: false,
application: null,
filter: null,
captureConsoleMinimumLevel: 'none',
breadcrumbs: false,
breadcrumbsNumber: 10
});
```

### Manual logging
*Works only with UMD Constructor !*
```javascript
var log = new Elmahio({
apiKey: 'YOUR-API-KEY',
logId: 'YOUR-LOG-ID',
});

log.verbose(msg);
log.verbose(msg, error);

log.debug(msg);
log.debug(msg, error);

log.information(msg);
log.information(msg, error);

log.warning(msg);
log.warning(msg, error);

log.error(msg);
log.error(msg, error);

log.fatal(msg);
log.fatal(msg, error);
```
Where __msg__ is a text string and __error__ is a [JavaScript Error Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error).

### Manual logging using console logging
*Works only with UMD Constructor !
console.log() is not available for logging !*
```javascript
var log = new Elmahio({
apiKey: 'YOUR-API-KEY',
logId: 'YOUR-LOG-ID',
captureConsoleMinimumLevel: 'debug' // options available: 'none', 'debug', 'info', 'warn', 'error'
});

// captureConsoleMinimumLevel: 'none' will disable logging from console;
// captureConsoleMinimumLevel: 'debug' will enable all of them - console.debug, console.info, console.warn, console.error;
// captureConsoleMinimumLevel: 'info' will enable - console.info, console.warn, console.error;
// captureConsoleMinimumLevel: 'warn' will enable - console.warn, console.error;
// captureConsoleMinimumLevel: 'error' will enable - console.error.

console.error('This is an %s message.', 'error');
console.warn('This is a %s message.', 'warning');
console.info('This is an %s message.', 'information');
console.debug('This is a %s message.', 'debug');
```

### Acknowledgments

* [Rojan Gharibpour](https://github.com/Sojaner)