Package Exports
- logdown
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (logdown) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
logdown.js
Logdown is a debug utility for the browser and the server with Markdown support. It does not have any dependencies and is only 2K gzipped.
You can see it in action in the example page or in the preview below.
Preview
Browser
Server
Installation
npm
If on the server, install it through npm:
npm install --save logdownvar Logdown = require('logdown')
var logger = new Logdown({prefix: 'foo'})Bower
In the browser you can install it through Bower:
bower install logdownvar logger = new Logdown({prefix: 'foo'})Other
You can also use the lib in the browser in the same way as in the server if you use Browserify. Or you can just download it here and put the dist/logdown.js file in your public folder. Another way of retrieving Logdown is via jsDelivr, a public Open Source CDN.
Import
SystemJS
Using the dynamic module loader SystemJS, Logdown can be loaded as a CommonJS module:
SystemJS.config({
map: {
'logdown': 'bower_components/logdown/dist/logdown.js'
},
packages: {
'logdown': {format: 'cjs'}
}
});System.import('logdown').then(function(Logdown) {
var logger = new Logdown({prefix: 'foo'}
});TypeScript
import Logdown = require("logdown");let logger: Logdown = new Logdown({prefix: 'foo'};Usage
Logging
It is highly recommended to use a prefix for your instance, this way you get a nice prefixed message on console and it is possible to silence instances based on the prefix name, as we will see after.
After creating your object, you can use the regular log, warn, info and error methods as we have on console, but now with Markdown support.
logger.log('lorem *ipsum*')
logger.info('dolor _sit_ amet')
logger.warn('consectetur `adipiscing` elit')You can pass multiple arguments
logger.log('lorem', '*ipsum*')
logger.info('dolor _sit_', 'amet')
logger.warn('consectetur', '`adipiscing` elit')Options
The constructor accepts one object for configuration on instantiation time.
Example
var options = {alignOutput: true, prefix: 'foo'}
var logger = new Logdown(options)The following options can be used for configuration.
prefix
- Type: 'String'
- Default:
''
var logger = new Logdown({prefix: 'foo'})
logger.log('Lorem ipsum') // Will use console.log with a prefixYou should use the name of your module.
You can, also, use : to separate modules inside one big module.
var fooBarLogger = new Logdown({prefix: 'foo:bar'})
fooBarLogger.log('Lorem ipsum')
var fooQuzLogger = new Logdown({prefix: 'foo:quz'})
fooQuzLogger.log('Lorem Ipsum')markdown
- Type: 'Boolean'
- Default:
true
If setted to false, markdown will not be parsed.
var logger = new Logdown({markdown: false})
logger.log('Lorem *ipsum*') // Will not parse the markdownFor Markdown, the following mark-up is supported:
// Bold with "*"" between words
logger.log('lorem *ipsum*')
// Italic with "_" between words
logger.log('lorem _ipsum_')
// Code with ` (backtick) between words
logger.log('lorem `ipsum`')alignOutput
- Type: 'Boolean'
- Default:
false
If setted to true, the name of the logger instance will have the same length as the longest name of any other Logdown instance.
Enabling/disabling instances
It is possible to enable/disable the output of instances using the
Logdown.disable or Logdown.enable methods.
Logdown.disable('foo') // will disable the instance with *foo* prefix
Logdown.enable('bar') // will enable the instance with *bar* prefixYou can also use wildcards.
Logdown.enable('*') // enables all instances
Logdown.disable('*') // disables all instances
Logdown.enable('foo*') // enables all instances with a prefix starting with *foo*Use - to do a negation.
// enables all instances but the one with *foo* prefix
Logdown.enable('*', '-foo')
// disables all intances with foo in the prefix, but don't disable *foobar*
Logdown.disable('*foo*', '-foobar')Credits
- Moleskine icon by Monika Ciapala
- Markdown icon by Dustin Curtis
Contributors
203 Caio Gondim
30 Benny Neugebauer
5 David Godfrey
2 Sven Anders Robbestad
1 Dan Lukinykh
1 Bent Cardan
1 Gleb Bahmutov
1 Panayiotis Lipiridis
1 netmmlDonating
If you found this library useful and are willing to donate, transfer some
bitcoins to 1BqqKiZA8Tq43CdukdBEwCdDD42jxuX9UY or through the
URL https://www.coinbase.com/caiogondim
Or via PayPal.me https://www.paypal.me/caiogondim.
caiogondim.com · GitHub @caiogondim · Twitter @caio_gondim