https://github.com/cheton/universal-logger-browser
  
  
    Browser plugins for universal logger. 
    https://github.com/cheton/universal-logger-browser
  
        Last synced: 3 months ago 
        JSON representation
    
Browser plugins for universal logger.
- Host: GitHub
- URL: https://github.com/cheton/universal-logger-browser
- Owner: cheton
- License: mit
- Created: 2017-05-10T08:06:29.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2019-08-27T11:51:53.000Z (about 6 years ago)
- Last Synced: 2024-10-30T00:00:16.215Z (about 1 year ago)
- Language: JavaScript
- Homepage: https://cheton.github.io/universal-logger-browser/
- Size: 130 KB
- Stars: 5
- Watchers: 2
- Forks: 0
- Open Issues: 0
- 
            Metadata Files:
            - Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
 
Awesome Lists containing this project
README
          # universal-logger-browser [](https://travis-ci.org/cheton/universal-logger-browser) [](https://coveralls.io/github/cheton/universal-logger-browser?branch=master)
[](https://www.npmjs.com/package/universal-logger-browser)
**Browser plugins for [universal logger](https://github.com/cheton/universal-logger/)**
#### Minimal

#### Styleable

 
## Installation
```bash
npm install --save universal-logger universal-logger-browser
```
## Usage
```js
import emoji from 'node-emoji';
import logger, { TRACE, INFO } from 'universal-logger';
import { minimal, styleable } from 'universal-logger-browser';
const log = logger()
    .use(minimal({
        showSource: true,
        useNativeConsoleMethods: true
    }))
    .use(styleable({
        showSource: true,
        showTimestamp: true,
        style: {
            level: {
                silly: { // Custom log level
                    backgroundColor: '#FFF',
                    border: '1px solid #222',
                    color: '#222',
                    lineHeight: 2,
                    padding: '2px 5px'
                }
            }
        }
    }))
    .on('log', (context, messages) => {
        // Custom log processing
    });
log.enableStackTrace();
log.setLevel(TRACE);
log.log(INFO, 'The logger has initialized');
log.trace(emoji.get('mostly_sunny'));
log.debug(emoji.get('sun_small_cloud'));
log.info(emoji.get('barely_sunny'));
log.warn(emoji.get('rain_cloud'));
log.error(emoji.get('lightning_cloud'));
```
## API
### Minimal
Name | Type | Default | Description 
:--- | :--- | :------ | :----------
formatter | function(context, messages) | | Custom log formatter.
showSource | boolean | true | Show the source line number of the caller.
Note that you need to call `log.enableStackTrace()` to capture stack frames.
useNativeConsoleMethods | boolean | true | Whether to use native console methods for trace, debug, info, warn, and error.
### Styleable
Name | Type | Default | Description 
:--- | :--- | :------ | :----------
colorized | boolean | true | Show colorized output.
showSource | boolean | true | Show the source line number of the caller.
Note that you need to call `log.enableStackTrace()` to capture stack frames.
showTimestamp | boolean | false | Show timestamp.
formatTimestamp | function(timestamp) | | Convert timestamp to string.
style | object | See [styleable-style.js](https://github.com/cheton/universal-logger-browser/blob/master/src/styleable-style.js) | Custom styles.
## License
MIT