1.0.1-beta.1 • Published 2 years ago

@lumbermill/browser v1.0.1-beta.1

Weekly downloads
-
License
MIT
Repository
-
Last release
2 years ago

@lumbermill/browser

Lumbermill is a logging library that has Markdown support, and allows for DEBUG="*" style logging, in both the browser or in nodejs. There are separate packages to keep bundle size small. This project borrows heavily from logdown.

This is the browser specific package of the lumbermill logging library. For use in other environments (currently just nodejs), see the parent project README.md.

Usage

This module provides bundles in a number of different formats for different use cases:

Use via webpack/rollup/another bundler

Simply import like any other es module.

import lumbermill from '@lumbermill/browser';

const log = lumbermill('my-bundled-app')

Include in html via CDN and \ tag

	<script src="<baseurl>/browser.iife.js"></script>
	<script>
		localStorage.debug = "*";
		const log = lumbermill('sample-iife', {
			app: 'sample-app',
		});
		log.info('hello world!');
	</script>

API

Create a new logger: lumbermill(prefix, opts)

prefix:

The prefix is basically the name of your logger. It has some fancy abilities however.

You can use globs to determine which loggers will have their output displayed:

Example prefixes:

  • my-app:some-feature:some-crazy-function
  • my-app:some-feature:another-crazy-function;
  • crazy-function
  • wild-function

Lumbermill allows your to selectively enable logs using wildcards. To enable logs, you set the debug variable in the browser's localStorage. For example:

// this will enable any loggers that have a prefix that starts with 'my-app',
// so from the above prefixes
// * `my-app:some-feature:some-crazy-function`
// * `my-app:some-feature:another-crazy-function`;
// would have their logs shown
localStorage.debug = 'my-app:*';

// this will enable any logger that ends with 'crazy-function',
// so from the above prefixes
// * `my-app:some-feature:some-crazy-function`
// * `my-app:some-feature:another-crazy-function`;
// * `crazy-function`
// would have their logs shown
localStorage.debug = '*crazy-function';

// this will enable any logger that has `feature` in the name,
// as well as any logger with the exact prefix 'wilf-function'
// so from the above prefixes
// * `my-app:some-feature:some-crazy-function`
// * `my-app:some-feature:another-crazy-function`;
// * `wild-function`
// would have their logs shown
localStorage.debug = '*feature*,wild-function';

You can also programatically enable a logger:

import lumbermill from '@lumbermill/browser';

const log = lumbermill('my-bundled-app');

log.state.isEnabled = true;

options:

Objects is an optional argument to the lumbermill function. It is a javascript object, with the following optional properties:

// the following shows the default values of opts
const opts = {
	// if markdown is true, then markdown within the log message will be parsed
	// and rendered in the log output.
	markdown: true, // default is true
	prefixColor: '#FFEE22', // default is auto chosen from the lumbermill.prefixColors array

	// defaults to console, you can specify a custom output logger
	// basically it takes any function on this object and wraps it
	logger: console,
}
2.0.0-beta.0

2 years ago

2.0.0-dev.1

2 years ago

2.0.0-dev.0

2 years ago

2.0.0-dev.3

2 years ago

2.0.0-dev.2

2 years ago

2.0.0-dev.5

2 years ago

2.0.0-dev.4

2 years ago

2.0.0-dev.7

2 years ago

2.0.0-dev.6

2 years ago

0.0.1-beta.0

2 years ago

1.0.1-beta.1

2 years ago

1.0.1-beta.0

2 years ago

1.0.1-alpha.0

3 years ago

1.0.0

3 years ago

1.0.0-beta.3

3 years ago

1.0.0-beta.2

3 years ago

1.0.0-beta.1

3 years ago

1.0.0-beta.0

3 years ago

0.0.1-alpha.9

3 years ago

0.0.1-alpha.8

3 years ago

0.0.1-alpha.7

3 years ago

0.0.1-alpha.6

3 years ago

0.0.1-alpha.5

3 years ago

0.0.1-alpha.4

3 years ago

0.0.1-alpha.3

3 years ago