Skip to content

Instantly share code, notes, and snippets.

@ag4ve
Created September 18, 2012 12:14
Show Gist options
  • Save ag4ve/3742798 to your computer and use it in GitHub Desktop.
Save ag4ve/3742798 to your computer and use it in GitHub Desktop.
trace and code snip
**** fr.js *****
log: function () { [native code] }
info: function () { [native code] }
warn: function () { [native code] }
error: function () { [native code] }
dir: function () { [native code] }
time: function () { [native code] }
timeEnd: function () { [native code] }
trace: function () { [native code] }
assert: function () { [native code] }
Console: function Console(stdout, stderr) {
if (!(this instanceof Console)) {
return new Console(stdout, stderr);
}
if (!stdout || typeof stdout.write !== 'function') {
throw new TypeError('Console expects a writable stream instance');
}
if (!stderr) {
stderr = stdout;
}
var prop = {
writable: true,
enumerable: false,
configurable: true
};
prop.value = stdout;
Object.defineProperty(this, '_stdout', prop);
prop.value = stderr;
Object.defineProperty(this, '_stderr', prop);
prop.value = {};
Object.defineProperty(this, '_times', prop);
// bind the prototype functions to this Console instance
Object.keys(Console.prototype).forEach(function(k) {
this[k] = this[k].bind(this);
}, this);
}
***** end ****
Loading data.js controller
/home/swilson/node/fr/node_modules/mongoose/node_modules/mongodb/lib/mongodb/con
nection/server.js:432
throw err;
^
TypeError: Cannot call method 'log' of undefined
at NativeConnection.<anonymous> (/home/swilson/node/fr/model/fr.js:22:22)
at NativeConnection.EventEmitter.emit (events.js:85:17)
at open (/home/swilson/node/fr/node_modules/mongoose/lib/connection.js:394:1
0)
at NativeConnection.Connection.onOpen (/home/swilson/node/fr/node_modules/mo
ngoose/lib/connection.js:401:5)
at Connection._open (/home/swilson/node/fr/node_modules/mongoose/lib/connect
ion.js:372:10)
at NativeConnection.doOpen (/home/swilson/node/fr/node_modules/mongoose/lib/
drivers/node-mongodb-native/connection.js:47:5)
###########
var fr = {
module: 'mongoose',
FR: {},
log: {},
init: function (app) {
this.log = app.settings.log;
console.log("**** fr.js *****");
for (var i in this.log) {
console.log(i + ": " + this.log[i]);
}
console.log("***** end ****");
var conn = app.settings.nconf.get("db:fr");
mongoose.connect(conn.string);
mongoose.connection.on('open', function() {
this.log.log("%s Connected to %s: %s ",
conn.name, conn.type, conn.string);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment