Code Monkey home page Code Monkey logo

elmah.io.javascript's Introduction

elmah.io.javascript

license

Log to elmah.io from JavaScript. For the most recent documentation, visit Logging to elmah.io from JavaScript.

Initialization

Immediately-Invoked Function Expression (IIFE)

<script src="elmahio.js?apiKey=YOUR-API-KEY&logId=YOUR-LOG-ID" type="text/javascript"></script>

UMD Constructor with options

<script src="elmahio.js" type="text/javascript"></script>
<script type="text/javascript">
  var log = new Elmahio({
    apiKey: 'YOUR-API-KEY',
    logId: 'YOUR-LOG-ID',
  });
</script>

Default options

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 !

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.

Manual logging using console logging

Works only with UMD Constructor ! console.log() is not available for logging !

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

elmah.io.javascript's People

Contributors

sojaner avatar thomasardal avatar zshare avatar

Watchers

 avatar  avatar  avatar  avatar

elmah.io.javascript's Issues

elmahio.js:1698 Uncaught TypeError: Cannot read property 'captureConsoleMinimumLevel' of undefined

Following steps here

  1. Install elmah.io.javascript Nuget package to new ASP.Net MVC web application
  2. Add <script> tag into _Layout page before other scripts immediately above closing </body> tag
  3. F5 launch ASP.Net application
  4. Default browser Microsoft Edge Version 85.0.564.44 (Official build) (64-bit)
  5. F12 developer tools, console tab, observe error, I think caused by options being undefined. (see IssueScreenshot.png in attached zip archive)

Attached ElmahJavascriptIssue.zip

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.