How to use the @node-red/util.log.trace function in @node-red/util

To help you get started, we’ve selected a few @node-red/util 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 node-red / node-red / packages / node_modules / @node-red / runtime / lib / storage / localfilesystem / projects / git / index.js View on Github external
function runGitCommand(args,cwd,env,emit) {
    log.trace(gitCommand + JSON.stringify(args));
    args.unshift("credential.helper=")
    args.unshift("-c");
    return exec.run(gitCommand, args, {cwd:cwd, detached:true, env:env}, emit).then(result => {
        return result.stdout;
    }).catch(result => {
        var stdout = result.stdout;
        var stderr = result.stderr;
        var err = new Error(stderr);
        err.stdout = stdout;
        err.stderr = stderr;
        if (/Connection refused/i.test(stderr)) {
            err.code = "git_connection_failed";
        } else if (/Connection timed out/i.test(stderr)) {
            err.code = "git_connection_failed";
        } else if (/fatal: could not read/i.test(stderr)) {
            // Username/Password
github node-red / node-red / packages / node_modules / @node-red / runtime / lib / storage / localfilesystem / projects / git / index.js View on Github external
function runGitCommandWithSSHCommand(args,cwd,auth,emit) {
    log.trace("runGitCommandWithSSHCommand "+JSON.stringify(auth).replace(/("pass.*?"\s*:\s*").+?"/g,'$1[hidden]"'));
    return sshResponseServer(auth).then(function(rs) {
        var commandEnv = clone(process.env);
        commandEnv.SSH_ASKPASS = path.join(__dirname,"node-red-ask-pass.sh");
        commandEnv.DISPLAY = "dummy:0";
        commandEnv.NODE_RED_GIT_NODE_PATH = process.execPath;
        commandEnv.NODE_RED_GIT_SOCK_PATH = rs.path;
        commandEnv.NODE_RED_GIT_ASKPASS_PATH = path.join(__dirname,"authWriter.js");
        // For git < 2.3.0
        commandEnv.GIT_SSH = path.join(__dirname,"node-red-ssh.sh");
        commandEnv.NODE_RED_KEY_FILE=auth.key_path;
        // GIT_SSH_COMMAND - added in git 2.3.0
        commandEnv.GIT_SSH_COMMAND = "ssh -i " + auth.key_path + " -F /dev/null";
        // console.log('commandEnv:', commandEnv);
        return runGitCommand(args,cwd,commandEnv,emit).then( result => {
            rs.close();
            return result;
github node-red / node-red / packages / node_modules / @node-red / editor-api / lib / editor / comms.js View on Github external
ws.on('message', function(data,flags) {
        var msg = null;
        try {
            msg = JSON.parse(data);
        } catch(err) {
            log.trace("comms received malformed message : "+err.toString());
            return;
        }
        if (!pendingAuth) {
            if (msg.subscribe) {
                self.subscribe(msg.subscribe);
                // handleRemoteSubscription(ws,msg.subscribe);
            }
        } else {
            var completeConnection = function(userScope,sendAck) {
                try {
                    if (!userScope || !Permissions.hasPermission(userScope,"status.read")) {
                        ws.send(JSON.stringify({auth:"fail"}));
                        ws.close();
                    } else {
                        pendingAuth = false;
                        addActiveConnection(self);
github node-red / node-red / packages / node_modules / @node-red / runtime / lib / storage / localfilesystem / projects / Project.js View on Github external
if (project.files.flow && !/\.\./.test(project.files.flow)) {
                var flowFilePath;
                var credsFilePath;

                if (project.migrateFiles) {
                    var baseFlowFileName = project.files.flow || fspath.basename(project.files.oldFlow);
                    var baseCredentialFileName = project.files.credentials || fspath.basename(project.files.oldCredentials);
                    files.push(baseFlowFileName);
                    files.push(baseCredentialFileName);
                    flowFilePath = fspath.join(projectPath,baseFlowFileName);
                    credsFilePath = fspath.join(projectPath,baseCredentialFileName);
                    if (fs.existsSync(project.files.oldFlow)) {
                        log.trace("Migrating "+project.files.oldFlow+" to "+flowFilePath);
                        promises.push(fs.copy(project.files.oldFlow,flowFilePath));
                    } else {
                        log.trace(project.files.oldFlow+" does not exist - creating blank file");
                        promises.push(util.writeFile(flowFilePath,"[]"));
                    }
                    log.trace("Migrating "+project.files.oldCredentials+" to "+credsFilePath);
                    runtime.nodes.setCredentialSecret(project.credentialSecret);
                    promises.push(runtime.nodes.exportCredentials().then(function(creds) {
                        var credentialData;
                        if (settings.flowFilePretty) {
                            credentialData = JSON.stringify(creds,null,4);
                        } else {
                            credentialData = JSON.stringify(creds);
                        }
                        return util.writeFile(credsFilePath,credentialData);
                    }));
                    delete project.migrateFiles;
                    project.files.flow = baseFlowFileName;
                    project.files.credentials = baseCredentialFileName;
github node-red / node-red / packages / node_modules / @node-red / runtime / lib / storage / localfilesystem / settings.js View on Github external
fs.readFile(globalSettingsFile,'utf8',function(err,data) {
                if (!err) {
                    try {
                        return resolve(util.parseJSON(data));
                    } catch(err2) {
                        log.trace("Corrupted config detected - resetting");
                    }
                }
                return resolve({});
            })
        })
github node-red / node-red / packages / node_modules / @node-red / runtime / lib / storage / localfilesystem / projects / ssh / index.js View on Github external
function generateSSHKeyPair(name, privateKeyPath, comment, password, size) {
    log.trace("ssh-keygen["+[name,privateKeyPath,comment,size,"hasPassword?"+!!password].join(",")+"]");
    return keygen.generateKey({location: privateKeyPath, comment: comment, password: password, size: size})
            .then(function(stdout) {
                return name;
            })
            .catch(function(err) {
                log.log('[SSHKey generation] error:', err);
                throw err;
            });
}
github node-red / node-red / packages / node_modules / @node-red / runtime / lib / storage / localfilesystem / sessions.js View on Github external
fs.readFile(sessionsFile,'utf8',function(err,data){
                if (!err) {
                    try {
                        return resolve(util.parseJSON(data));
                    } catch(err2) {
                        log.trace("Corrupted sessions file - resetting");
                    }
                }
                resolve({});
            })
        });
github node-red / node-red / packages / node_modules / @node-red / runtime / lib / storage / localfilesystem / projects / git / index.js View on Github external
function runGitCommandWithAuth(args,cwd,auth,emit) {
    log.trace("runGitCommandWithAuth "+JSON.stringify(auth).replace(/("pass.*?"\s*:\s*").+?"/g,'$1[hidden]"'));
    return authResponseServer(auth).then(function(rs) {
        var commandEnv = clone(process.env);
        commandEnv.GIT_ASKPASS = path.join(__dirname,"node-red-ask-pass.sh");
        commandEnv.NODE_RED_GIT_NODE_PATH = process.execPath;
        commandEnv.NODE_RED_GIT_SOCK_PATH = rs.path;
        commandEnv.NODE_RED_GIT_ASKPASS_PATH = path.join(__dirname,"authWriter.js");
        return runGitCommand(args,cwd,commandEnv,emit).then( result => {
            rs.close();
            return result;
        }).catch(err => {
            rs.close();
            throw err;
        });
    })
}