Skip to content

Instantly share code, notes, and snippets.

@wildskyf
Last active March 14, 2017 10:36
Show Gist options
  • Save wildskyf/2da308f400fc304d4b68de0d639dfe96 to your computer and use it in GitHub Desktop.
Save wildskyf/2da308f400fc304d4b68de0d639dfe96 to your computer and use it in GitHub Desktop.
console.log()
console.info()
console.warn()
console.error()

Log Wrapper: https://www.paulirish.com/2009/log-a-lightweight-wrapper-for-consolelog/

Library enhancing the console

Think another way

Log to server

why?

  1. You can capture log entries from your application without being physically at the computer (perfect in production)
  2. You can manage your server-side and client-side logs in the same place, potentially using the same tools
  3. You can set up alerts (e.g. a Slack notification or SMS if a critical error occurs)
  4. Where the console isn’t available or is difficult to view (e.g. when using a mobile’s web view) it’s easier to see what’s going on

limits

  1. Most logging mechanisms allow you to configure a minimum logging level so that you can filter out certain entries
  2. It will send log entries immediately, which could lead to your server-side component becoming overloaded

great library:

(The author provides an example in Roll Your Own Batch-Compatible Logger, see code there.)


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment