How to use the loglevel.levels function in loglevel

To help you get started, we’ve selected a few loglevel examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github MyScript / MyScriptJS / src / configuration / LoggerConfig.js View on Github external
import * as log from 'loglevel';

const logger = log.noConflict();
logger.setDefaultLevel(log.levels.ERROR);
logger.setLevel(log.levels.ERROR); // TRACE,DEBUG,INFO,ERROR

/**
 * Log editor events
 * @type {Object}
 */
const editorLogger = logger.getLogger('editor');
editorLogger.setDefaultLevel(log.levels.ERROR); // TRACE,DEBUG,INFO,ERROR
editorLogger.setLevel(logger.getLevel());

/**
 * Log model events
 * @type {Object}
 */
const modelLogger = logger.getLogger('model');
modelLogger.setDefaultLevel(log.levels.ERROR); // TRACE,DEBUG,INFO,ERROR
github kiibohd / configurator / src / main / index.js View on Github external
import { app, BrowserWindow, ipcMain as ipc } from 'electron';
import * as path from 'path';
import { format as formatUrl } from 'url';
import * as usb from './usb';
import { isKnownDevice, getDevice } from '../common/device/keyboard';
import { identifyKeyboard } from './keyboard';
import { buildMenu } from './menu';
import Bluebird from 'bluebird';
import log from 'loglevel';

const isDevelopment = process.env.NODE_ENV === 'development';
log.setDefaultLevel(isDevelopment ? log.levels.INFO : log.levels.ERROR);

// global reference to mainWindow (necessary to prevent window from being garbage collected)
let mainWindow;

function createMainWindow() {
  const window = new BrowserWindow({
    width: isDevelopment ? 2300 : 1800,
    height: 1100,
    webPreferences: {
      webSecurity: false,
      nodeIntegration: true
    }
  });

  if (isDevelopment) {
    window.webContents.openDevTools();
github kiibohd / configurator / src / renderer / state / settings.js View on Github external
import _ from 'lodash';
import log from 'loglevel';
import { createSharedState } from '../shared-state/index';
import db from '../db';
import { findDfuPath } from '../local-storage/dfu-util';
import { findKiidrvPath } from '../local-storage/kiidrv';

const dev = process.env.NODE_ENV === 'development';

log.setDefaultLevel(dev ? log.levels.INFO : log.levels.ERROR);

// const defaultUri = dev ? 'http://localhost:8080' : 'http://vash.input.club:80';
const defaultUri = 'http://vash.input.club';

const DbKey = {
  dfuPath: 'dfu-path',
  kiidrvPath: 'kiidrv-path',
  lastDl: 'last-download',
  recentDls: 'recent-dls',
  lastVerCheck: 'last-version-check',
  firmwareVersions: 'firmware-versions',
  cannedAnimations: 'canned-animations',
  uri: dev ? 'uri-development' : 'uri-production'
};

/**
github CityOfZion / neo-js / dist / common / logger.js View on Github external
constructor (name, options = {}) {
    // TODO: refactor formatting with usage of defaultOptions
    // TODO: support text color setting
    // TODO: create an enum to store color values
    this.name = name

    // Associate class properties
    Object.assign(this, {
      level: loglevel.levels.WARN,
      displayTimestamp: true,
      displayName: true,
      displayLevel: true,
      timestampFormat: 'hh:mm:ss.SSS'
    }, options)

    // Bootstrapping
    this.logger = loglevel.getLogger(this.name)
    this.logger.setLevel(this.level)
  }
github esrlabs / chipmunk / application / apps / indexer-neon / src / tests.ts View on Github external
export function testDltIndexingAsync(
    fileToIndex: string,
    outPath: string,
    timeoutMs: number,
    fibexPath?: string,
) {
    log.setDefaultLevel(log.levels.DEBUG);
    log.debug(`testDltIndexingAsync for ${fileToIndex} (out: "${outPath}")`);
    let helper = new IndexingHelper("dlt async indexing");
    try {
        const filterConfig: DltFilterConf = {
            min_log_level: DltLogLevel.Debug,
        };
        const dltParams: IIndexDltParams = {
            dltFile: fileToIndex,
            filterConfig,
            fibex: fibexPath,
            tag: "TAG",
            out: outPath,
            chunk_size: 500,
            append: false,
            stdout: false,
            statusUpdates: true,
github muuvmuuv / vscode-sundial / src / logger.ts View on Github external
import logger from 'loglevel'

const originalFactory = logger.methodFactory

logger.methodFactory = (methodName, logLevel, loggerName) => {
  const rawMethod = originalFactory(methodName, logLevel, loggerName)
  const devider = ':'
  const name = loggerName ? devider + loggerName : ''
  const prefix = `(Sundial${name}) => `

  return (...messages) => {
    rawMethod(prefix, ...messages)
  }
}

logger.setDefaultLevel(logger.levels.INFO)

function setGlobalLevel(level: any) {
  Object.values(logger.getLoggers()).forEach((lg) => {
    lg.setLevel(level)
  })
}

export { logger, setGlobalLevel }
github CityOfZion / neo-js / dist / common / logger.js View on Github external
static get levels () {
    return loglevel.levels
  }
github bitlum / bitlum-front / app / sources / src / utils / logging.js View on Github external
} catch (e) {}
        }
        formattedMessage = `${errorObject.message} (${errorObject.code || 0}) ${stack}`;
      }
    }

    return rawMethod(prefix, formattedMessage);
  };
};

if (process.env.NODE_ENV === 'development') {
  loglevel.setDefaultLevel(loglevel.levels.DEBUG);
  loglevel.setLevel(loglevel.levels.DEBUG);
}
if (process.env.NODE_ENV === 'production') {
  loglevel.setDefaultLevel(loglevel.levels.INFO);
  loglevel.setLevel(loglevel.levels.INFO);
}
if (process.env.NODE_ENV === 'test') {
  loglevel.setDefaultLevel(loglevel.levels.SILENT);
  loglevel.setLevel(loglevel.levels.SILENT);
}

const internalLogger = loglevel.getLogger('Logger');

export default name => ({ ...loglevel.getLogger(name || 'general') });
github atlasmap / atlasmap / ui-react / packages / atlasmap-core / src / services / initialization.service.ts View on Github external
Copyright (C) 2017 Red Hat, Inc.

    Licensed under the Apache License, Version 2.0 (the "License");
    you may not use this file except in compliance with the License.
    You may obtain a copy of the License at

            http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.
*/
import log from 'loglevel';
log.setDefaultLevel(log.levels.TRACE);
import { inflate } from 'pako';
import { Subject, Observable } from 'rxjs';

import { DocumentType, InspectionType, CollectionType } from '../common/config.types';
import { DataMapperUtil } from '../common/data-mapper-util';
import { DocumentInitializationModel, ConfigModel } from '../models/config.model';
import { DocumentDefinition } from '../models/document-definition.model';
import { MappingDefinition } from '../models/mapping-definition.model';

import { ErrorHandlerService } from './error-handler.service';
import { DocumentManagementService } from './document-management.service';
import { MappingManagementService } from './mapping-management.service';
import { FieldActionService } from './field-action.service';
import { FileManagementService } from './file-management.service';
import { LookupTableUtil } from '../utils/lookup-table-util';
import { MappingSerializer } from '../utils/mapping-serializer';