How to use the infusion.logLevel function in infusion

To help you get started, we’ve selected a few infusion 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 GPII / universal / scripts / deleteExpiredAccessTokens.js View on Github external
// node deleteExpiredAccessTokens.js $COUCHDBURL [--deleteAll]
// where COUCHDBURL is the url to database, e.g. http://localhost:5984/gpii
// The optional --deleteAll argument removes all of the access token records
// regardless of their time of expiration.
//
"use strict";

var url = require("url"),
    fluid = require("infusion");

fluid.require("%gpii-universal/scripts/shared/dbRequestUtils.js");

var gpii = fluid.registerNamespace("gpii");
fluid.registerNamespace("gpii.accessTokens");

fluid.setLogging(fluid.logLevel.INFO);

// Handle command line
if (process.argv.length < 3) {
    fluid.log("Usage: node deleteExpiredAccessTokens.js $COUCHDB_URL [--deleteAll]");
    process.exit(1);
}

/**
 * Create a set of options for this script.
 * The options are based on the command line parameters and a set of database
 * constants.
 * @param {Array} processArgv - The command line arguments.
 * @return {Object} - The options.
 */
gpii.accessTokens.initOptions = function (processArgv) {
    var options = {};
github GPII / universal / scripts / deleteAndLoadSnapsets.js View on Github external
// There is also an optional final [--justDelete] argument for testing/debugging.
// If present, the script exits with a zero exit status after deleting all the
// snapset PrefsSafes and their GPII keys.  That is, the script does only the
// first four steps listed above.

"use strict";

var http = require("http"),
    url = require("url"),
    fs = require("fs"),
    fluid = require("infusion");

var gpii = fluid.registerNamespace("gpii");
fluid.registerNamespace("gpii.dataLoader");

fluid.setLogging(fluid.logLevel.INFO);

// Handle command line
if (process.argv.length < 5) {
    fluid.log("Usage: node deleteAndLoadSnapsets.js $COUCHDB_URL $STATIC_DATA_DIR $BUILD_DATA_DIR [--justDelete]");
    process.exit(1);
}

/**
 * Create a set of options for data loader and a function to retreive them.
 * The options are based on the command line parameters and a set of database
 * constants.
 * @param {Array} processArgv - The command line arguments.
 * @return {Object} - The options.
 */
gpii.dataLoader.initOptions = function (processArgv) {
    var dbOptions = {};
github GPII / universal / index.js View on Github external
gpii.stop = function () {
    // Destroy the configs in reverse order, so the first loaded one is destroyed last.
    // There should properly never be more than one - see https://github.com/GPII/universal/pull/766
    var configs = gpii.queryConfigs().reverse();
    if (configs.length > 1) {
        fluid.log(fluid.logLevel.WARN, "Error during gpii.stop - found more than one active config: ", configs);
    }
    fluid.each(configs, function (config) {
        config.destroy();
    });
};
github GPII / universal / gpii / node_modules / eventLog / src / eventLog.js View on Github external
gpii.eventLog.writeLog = function (that, level, event) {
    var intLevel = gpii.eventLog.checkLevel(level);
    event.level = intLevel.value;

    // Log to console before the installation ID and timestamp are added (no one wants to see it).
    fluid.log(fluid.logLevel.IMPORTANT, event);

    event.installID = that.installationID;
    event.timestamp = gpii.eventLog.getTimestamp();
    fs.appendFileSync(that.logFilePath, JSON.stringify(event) + "\n");
};
github GPII / universal / gpii / node_modules / journal / src / SettingsDir.js View on Github external
gpii.settingsDir.createGpii = function (that) {
    fluid.log(fluid.logLevel.WARN, "Creating GPII settings directory in ", that.gpiiSettingsDir);
    try { // See code skeleton in http://stackoverflow.com/questions/13696148/node-js-create-folder-or-use-existing
        fs.mkdirSync(that.gpiiSettingsDir);
    } catch (e) {
        if (e.code !== "EEXIST") {
            fluid.fail("Unable to create GPII settings directory, code is " + e.code + ": exception ", e);
        }
    }
};
github GPII / universal / gpii / node_modules / eventLog / src / eventLog.js View on Github external
gpii.eventLog.logError = function (that, moduleName, errType, err, level) {
    if (!level) {
        level = fluid.logLevel.FAIL;
    }

    var data = {};
    if (err instanceof Error) {
        // Error doesn't serialise
        data.error = {};
        fluid.each(Object.getOwnPropertyNames(err), function (a) {
            data.error[a] = err[a];
        });
    } else if (fluid.isPlainObject(err, true)) {
        data.error = Object.assign({}, err);
    } else {
        data.error = {
            message: err
        };
    }
github GPII / universal / gpii / node_modules / lifecycleManager / src / UserLogonStateChange.js View on Github external
}, function (error) {
        fluid.log(fluid.logLevel.FAIL, "Error returned from lifecycle manager: ", error);
        lifecycleManager.errorResponse(that, "Error occurred during login: " + error.message);
    });
};
github GPII / universal / gpii / node_modules / userListeners / src / pcsc.js View on Github external
that.pcsclite.on("error", function (err) {
                fluid.log(fluid.logLevel.ERROR, "PCSC error", err);
                that.failed(err);
            });
            promise.resolve();
github GPII / universal / gpii / node_modules / journal / src / Journal.js View on Github external
gpii.journal.findCrashed = function (that) {
    var firstCrashed = fluid.find_if(that.journalFiles, function (journalFile) {
        return journalFile.closed === false;
    });
    if (firstCrashed) {
        that.crashedJournal = firstCrashed;
        fluid.log(fluid.logLevel.WARN, "Found crashed journal file on startup: " + JSON.stringify(firstCrashed, null, 2));
    } else {
        fluid.log("Found no crashed journals on startup");
    }
};
github GPII / universal / gpii / node_modules / userListeners / src / listeners.js View on Github external
gpii.userListeners.failed = function (that, err) {
    var delay = Math.min(that.failCount++, 10) * that.options.failDelay;

    fluid.log(fluid.logLevel.WARN,
        "Listener " + that.listenerName + " has failed. Restarting in " + delay + " seconds");

    that.events.onFail.fire(that, err);

    process.nextTick(function () {
        that.stopListener().then(function () {
            setTimeout(function () {
                fluid.log("Restarting " + that.listenerName + " listener");
                that.startListener();
            }, delay * 1000);
        });
    });
};