How to use log - 10 common examples

To help you get started, we’ve selected a few log 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 traveloka / slack-robot / test / Robot.js View on Github external
it('should listen to authenticated event from websocket', () => {
    // use stub to prevent actual call to websocket
    const robot = new Robot('token');
    const wsStartStub = sinon.stub(RtmClient.prototype, 'start');
    const wsMessageStub = sinon.stub(RtmClient.prototype, 'on');
    const loggerStub = sinon.stub(Log.prototype, 'info');

    // mock dataStore
    const botUserMock = {
      id: 5,
      name: 'slackbot'
    };
    robot._rtm.activeUserId = 5;
    robot._rtm.dataStore = {
      getUserById: sinon.stub().withArgs(robot._rtm.activeUserId).returns(botUserMock)
    };

    wsMessageStub.withArgs('authenticated').callsArg(1);

    // start to listen
    robot.start();
github arangodb / arangodb / js / client / modules / @arangodb / testing / utils.js View on Github external
port = findFreePort(options.maxPort);
    endpoint = protocol + '://127.0.0.1:' + port;
  } else {
    endpoint = addArgs['server.endpoint'];
    port = endpoint.split(':').pop();
  }

  let instanceInfo = {
  role, port, endpoint, rootDir};

  args['server.endpoint'] = endpoint;
  args['database.directory'] = dataDir;
  args['log.file'] = fs.join(rootDir, 'log');

  if (options.verbose) {
    args['log.level'] = 'info';
  } else {
    args['log.level'] = 'error';
  }

  // flush log messages directly and not asynchronously
  // (helps debugging)  
  args['log.force-direct'] = 'true';

  if (protocol === 'ssl') {
    args['ssl.keyfile'] = fs.join('UnitTests', 'server.pem');
  }

  args = Object.assign(args, options.extraArgs);

  if (addArgs !== undefined) {
    args = Object.assign(args, addArgs);
github arangodb / arangodb / js / client / modules / @arangodb / testing / utils.js View on Github external
let port;

  if (!addArgs['server.endpoint']) {
    port = findFreePort(options.maxPort);
    endpoint = protocol + '://127.0.0.1:' + port;
  } else {
    endpoint = addArgs['server.endpoint'];
    port = endpoint.split(':').pop();
  }

  let instanceInfo = {
  role, port, endpoint, rootDir};

  args['server.endpoint'] = endpoint;
  args['database.directory'] = dataDir;
  args['log.file'] = fs.join(rootDir, 'log');

  if (options.verbose) {
    args['log.level'] = 'info';
  } else {
    args['log.level'] = 'error';
  }

  // flush log messages directly and not asynchronously
  // (helps debugging)  
  args['log.force-direct'] = 'true';

  if (protocol === 'ssl') {
    args['ssl.keyfile'] = fs.join('UnitTests', 'server.pem');
  }

  args = Object.assign(args, options.extraArgs);
github ballerina-platform / ballerina-lang / composer / diagram / src / plugins / ballerina / model / tree / compilation-unit-node.js View on Github external
addImport(importNode, silent) {
        const pkgName = this.getPackageName(importNode);
        if (this.isExistingPackage(pkgName)) {
            const errorString = 'Package "' + pkgName + '" is already imported.';
            log.debug(errorString);
            return;
        }
        const pkgDeclIndex = _.findLastIndex(this.getTopLevelNodes(), node => TreeUtils.isPackageDeclaration(node));
        const lastImportIndex = _.findLastIndex(this.getTopLevelNodes(), node => TreeUtils.isImport(node));
        let targetIndex = 0; // If there is no a pck node or any import, we'll add it to 0
        if (lastImportIndex !== -1) {
            targetIndex = lastImportIndex + 1;
        } else if (pkgDeclIndex !== -1) {
            targetIndex = pkgDeclIndex + 1;
        }

        let startIndex = 0;
        let insertBefore = this.topLevelNodes[targetIndex];
        if(insertBefore !== undefined){
            const wsList = ASTUtil.extractWS(insertBefore);
            if(wsList.length > 0){
github humhub / humhub / static / js / humhub / humhub.ui.status.js View on Github external
} else {
                if (error.error instanceof Error) {
                    error.stack = (error.error.stack) ? error.error.stack : undefined;
                    error.error = error.error.message;
                } else if (error instanceof client.Response) {
                    error = error.getLog();
                }
                try {
                    // encode
                    return $('<div>').text(JSON.stringify(error, null, 4)).html();
                } catch (e) {
                    return error.toString();
                }
            }
        } catch (e) {
            log.error(e);
        }
    };
</div>
github ballerina-platform / ballerina-lang / modules / web / js / ballerina / views / ballerina-file-editor.js View on Github external
this._$designViewContainer = container;
        var canvasContainer = $('<div></div>');
        canvasContainer.addClass(_.get(viewOptions, 'cssClass.canvas_container'));
        var canvasTopControlsContainer = $('<div></div>')
            .addClass(_.get(viewOptions, 'cssClass.canvas_top_controls_container'))
            .append($('<div></div>').addClass(_.get(viewOptions, 'cssClass.canvas_top_control_package_define')))
            .append($('<div></div>').addClass(_.get(viewOptions, 'cssClass.canvas_top_control_packages_import')))
            .append($('<div></div>').addClass(_.get(viewOptions, 'cssClass.canvas_top_control_constants_define')));
        canvasContainer.append(canvasTopControlsContainer);

        this._$designViewContainer.append(canvasContainer);
        this._$canvasContainer = canvasContainer;
        // check whether container element exists in dom
        if (!container.length &gt; 0) {
            errMsg = 'unable to find container for file composer with selector: ' + _.get(viewOptions, 'design_view.container');
            log.error(errMsg);
            throw errMsg;
        }

        var toolPaletteItemProvider = new ToolPaletteItemProvider();
        var toolPaletteContainer = $(this._container)
                                    .find(_.get(viewOptions, 'design_view.tool_palette.container'))
                                    .get(0);
        var toolPaletteOpts = _.clone(_.get(viewOptions, 'design_view.tool_palette'));
        toolPaletteOpts.itemProvider = toolPaletteItemProvider;
        toolPaletteOpts.container = toolPaletteContainer;
        toolPaletteOpts.ballerinaFileEditor = this;
        this.toolPalette = new ToolPalette(toolPaletteOpts);

        this._createImportDeclarationPane(canvasContainer);

        // init undo manager
github ballerina-platform / ballerina-lang / composer / diagram / src / plugins / ballerina / views / ballerina-file-editor.jsx View on Github external
goToSource(node) {
        if (!_.isNil(node)) {
            const { position, type } = node;
            // If node has position info
            if (position) {
                const { startLine, startColumn } = position;
                this.jumpToSourcePosition(startLine - 1, startColumn - 1);
            } else {
                log.error(`Unable to find location info from ${type} node.`);
            }
        } else {
            log.error('Invalid node to find source line.');
        }
    }
github appcelerator-developer-relations / appc-sample-ti520 / app / controllers / ios / livephoto.js View on Github external
function handleResponse(e) {
  log.args('Ti.Media.openPhotoGallery', e);

  if (!e.success) {
    return alert(e.error || 'Error #' + e.code);
  }

  if (e.mediaType !== Ti.Media.MEDIA_TYPE_LIVEPHOTO) {
    return alert('This should never happen. We required a Live Photo but somehow you selected something else.');
  }

  if (!e.livePhoto) {
    return alert('This should never happen. If mediaType says you selected a Live Photo it should be there.');
  }

  $.livePhotoView.livePhoto = e.livePhoto;

  // Programmatically triggering playback isn't recommended in any other use case
github appcelerator-developer-relations / appc-sample-ti510 / app / controllers / permissions.js View on Github external
function calendar(e) {

	// The new cross-platform way to check permissions
	var hasCalendarPermissions = Ti.Calendar.hasCalendarPermissions();
	log.args('Ti.Calendar.hasCalendarPermissions', hasCalendarPermissions);

	if (hasCalendarPermissions) {

		// We have to actually use a Ti.Calendar method for the permissions to be generated
		// FIXME: https://jira.appcelerator.org/browse/TIMOB-19933
		log.args('Ti.Calendar.getAllCalendars', Ti.Calendar.getAllCalendars());

		return alert('You already have permission.');
	}

	// On iOS we can get information on the reason why we might not have permission
	if (OS_IOS) {

		// Map constants to names
		var map = {};
		map[Ti.Calendar.AUTHORIZATION_AUTHORIZED] = 'AUTHORIZATION_AUTHORIZED';
github appcelerator-developer-relations / appc-sample-ti510 / app / controllers / ios.js View on Github external
log.args('Starting unoptimized operations..');

		collection.forEach(function(model, n) {

			// do something heavy, like creating rows to add to a table
			Ti.Platform.createUUID();

			$.progressBar.value = progressAsc ? n : (Alloy.CFG.threadOperations - 1 - n);

		});

		progressAsc = !progressAsc;
		progressRunning = false;

		log.args('Finished operations..');
	}

	// OPTIMIZED CODE

	// If the switch is on use code optimized for single thread.
	// Result will be ~ same if main thread is DISABLED or ENABLED
	// because each call to $.progress.value will be either executed inmediately (DISABLED)
	// or before the next call to doSomething, which is stacked after it.

	// Use Underscore's _.defer()
	if (e.index === 1) {

		log.args('Starting operations optimized using _.defer() ..');

		function doSomething(n) {