Skip to content
Snippets Groups Projects
Select Git revision
  • f39750dfb8fe96474017da1ebdfc52222fa7a7f7
  • master default protected
  • 1.31
  • 4.38.3
  • 4.38.2
  • 4.38.1
  • 4.38.0
  • 4.37.2
  • 4.37.1
  • 4.37.0
  • 4.36.0
  • 4.35.0
  • 4.34.1
  • 4.34.0
  • 4.33.1
  • 4.33.0
  • 4.32.2
  • 4.32.1
  • 4.32.0
  • 4.31.0
  • 4.30.1
  • 4.30.0
  • 4.29.1
23 results

customelement.mjs

Blame
  • console.mjs 1.29 KiB
    'use strict';
    
    /**
     * @author schukai GmbH
     */
    
    import {Base} from '../../types/base.mjs';
    import {getGlobalObject} from "../../types/global.mjs";
    import {Handler} from '../handler.mjs';
    import {LogEntry} from "../logentry.mjs";
    
    export {ConsoleHandler}
    
    /**
     * You can create an object of the class simply by using the namespace `new Monster.Logging.Handler.ConsoleHandler()`.
     * 
     * ```
     * <script type="module">
     * import {ConsoleHandler} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@latest/source/logging/handler/console.mjs';
     * console.log(new ConsoleHandler())
     * </script>
     * ```
     *
     * @since 1.5.0
     * @copyright schukai GmbH
     * @memberOf Monster.Logging.Handler
     */
     class ConsoleHandler extends Handler {
        constructor() {
            super();
        }
    
    
        /**
         * This is the central log function. this method must be
         * overwritten by derived handlers with their own logic.
         *
         * ALL > TRACE > DEBUG > INFO > WARN > ERROR > FATAL > OFF  (ALL = 0xff;OFF = 0x00;
         *
         * @param {LogEntry} entry
         * @returns {boolean}
         */
        log(entry) {
            if (super.log(entry)) {
                let console = getGlobalObject('console');
                if (!console) return false;
                console.log(entry.toString());
                return true;
            }
    
            return false;
        }
    
    }