Commit a0413802 authored by Rene Saarsoo's avatar Rene Saarsoo
Browse files

Log messages of extract.js script to stderr.

This way the stdout can be directed to file and the file will only
contain SQL that can be fed into MySQL.

Also added error message when connecting to mongodb fails.
parent 69c8f0d5
Loading
Loading
Loading
Loading
+7 −1
Original line number Diff line number Diff line
@@ -69,5 +69,11 @@ Meta = mongoose.model('Meta', new mongoose.Schema({
}));

mongoose.connect(config.mongoDb, function(err, ok) {
    console.log("Connected to DB")
    if (err) {
        console.warn("Unable to connect to MongoDB");
        console.warn(err);
    }
    else {
        console.warn("Connected to MongoDB");
    }
});
+8 −8
Original line number Diff line number Diff line
@@ -462,7 +462,7 @@ function addIds(objects) {

function asyncPrint(msg) {
    return function(data, next) {
        console.log(msg);
        console.warn(msg);
        next();
    };
}
@@ -514,13 +514,13 @@ sequence({}, [
    ReadingsTable.extract,

    function(data, next) {
        console.log(data.users.length + " users");
        console.log(data.targets.length + " targets");
        console.log(data.comments.length + " comments");
        console.log(data.votes.length + " votes");
        console.log(data.updates.length + " updates");
        console.log(data.subscriptions.length + " subscriptions");
        console.log(data.readings.length + " readings");
        console.warn(data.users.length + " users");
        console.warn(data.targets.length + " targets");
        console.warn(data.comments.length + " comments");
        console.warn(data.votes.length + " votes");
        console.warn(data.updates.length + " updates");
        console.warn(data.subscriptions.length + " subscriptions");
        console.warn(data.readings.length + " readings");
        next();
    },