1.0.2 • Published 2 years ago

betterlogger.js v1.0.2

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

BetterLogger.js


Better Logging in NodeJS and Websites ( Browser Console )

This is a better logger for nodejs and web applications


Import BetterLogger.JS

NodeJS

Install module: npm install betterlogger.js

var { StaticLogger, Logger } = require('betterlogger.js');

var logger = new Logger('Main', 'main').setDebugging(99);

logger.info('info');
logger.log('log');
logger.notice('notice');
logger.debug('debug');
logger.alert('alert');
logger.warning('warning');
logger.request('request');
logger.debugExtensive('debugExtensive');
logger.logError(new Error('Kakamalaka'));
logger.out('out', 'out');

StaticLogger.setDebugging(99);
StaticLogger.info('info');
StaticLogger.log('log');
StaticLogger.notice('notice');
StaticLogger.debug('debug');
StaticLogger.alert('alert');
StaticLogger.warning('warning');
StaticLogger.request('request');
StaticLogger.debugExtensive('debugExtensive');
StaticLogger.logError(new Error('Kakamalaka'));
StaticLogger.out('out', 'out');

Plain html import and usage

<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8" />
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="viewport" content="width=device-width, initial-scale=1.0" />
        <title>Document</title>

        <!-- Import Logger -->
        <script src="https://unpkg.com/betterlogger.js@latest/dist/logger.js"></script>
    </head>
    <body>
        <!-- Use Logger -->
        <script>
            var logger = new Logger('Main', 'main').setDebugging(99);

            logger.info('info');
            logger.log('log');
            logger.notice('notice');
            logger.debug('debug');
            logger.alert('alert');
            logger.warning('warning');
            logger.request('request');
            logger.debugExtensive('debugExtensive');
            logger.logError(new Error('Kakamalaka'));
            logger.out('out', 'out');

            StaticLogger.setDebugging(99);
            StaticLogger.info('info');
            StaticLogger.log('log');
            StaticLogger.notice('notice');
            StaticLogger.debug('debug');
            StaticLogger.alert('alert');
            StaticLogger.warning('warning');
            StaticLogger.request('request');
            StaticLogger.debugExtensive('debugExtensive');
            StaticLogger.logError(new Error('Kakamalaka'));
            StaticLogger.out('out', 'out');
        </script>
    </body>
</html>

React / Other Modular scripts

Install module or load from cdn: npm install betterlogger.js

Usage:

<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8" />
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="viewport" content="width=device-width, initial-scale=1.0" />
        <title>Document</title>
    </head>
    <body>
        <script type="module">
            import { Logger, StaticLogger } from 'node_modules/betterlogger.js/src/web-logger.js';
            // or
            import { Logger, StaticLogger } from 'betterlogger.js';
            // depends on how your imports gets managed...

            var logger = new Logger('Main', 'main').setDebugging(99);

            logger.info('info');
            logger.log('log');
            logger.notice('notice');
            logger.debug('debug');
            logger.alert('alert');
            logger.warning('warning');
            logger.request('request');
            logger.debugExtensive('debugExtensive');
            logger.logError(new Error('Kakamalaka'));
            logger.out('out', 'out');

            StaticLogger.setDebugging(99);
            StaticLogger.info('info');
            StaticLogger.log('log');
            StaticLogger.notice('notice');
            StaticLogger.debug('debug');
            StaticLogger.alert('alert');
            StaticLogger.warning('warning');
            StaticLogger.request('request');
            StaticLogger.debugExtensive('debugExtensive');
            StaticLogger.logError(new Error('Kakamalaka'));
            StaticLogger.out('out', 'out');
        </script>
    </body>
</html>