You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
First there is a little mistake on the github publication :
var MongoDB = require('winston-mongoDB').MongoDB;
When I tried to make the module work, I saw that the require is not 'winston-mongoDB' but 'winston-mongodb'.
So, I need to make some logs of actions done by users on a website. My work is in node.js
I am trying to make working winston-mongodb to store a log (for example, a sentence) in a mongodb database
I installed mongodb on a ubuntu 10.04. Here is my source code in CoffeeScript, and in Javascript.
winston = require('winston');
winston.log('info', 'The personId : ' + @personId + ' did a preference Action of : ' + @preferenceAction + ' on the entity Id:' + @entityId + ' Type:' + @entityType);
MongoDB = require('winston-mongodb').MongoDB;
options = { db: 'log' };
winston.add(MongoDB, options);
module.exports = CreateLogPreference;
Converted in javascript :
(function() {
var CreateLogPreference;
CreateLogPreference = (function() {
function CreateLogPreference(personId, preferenceAction, entityType, entityId) {
var MongoDB, options, winston;
if (personId == null) {
personId = 1;
}
if (preferenceAction == null) {
preferenceAction = 'test';
}
if (entityType == null) {
entityType = 'truc';
}
if (entityId == null) {
entityId = 1;
}
this.personId = personId;
this.preferenceAction = preferenceAction;
this.entityType = entityType;
this.entityId = entityId;
winston = require('winston');
winston.log('info', 'The personId : ' + this.personId + ' did a preference Action of : ' + this.preferenceAction + ' on the entity Id:' + this.entityId + ' Type:' + this.entityType);
MongoDB = require('winston-mongodb').MongoDB;
options = {
db: 'log'
};
winston.add(MongoDB, options);
}
return CreateLogPreference;
})();
module.exports = CreateLogPreference;
}).call(this);
Then I use this code :
var Logger = require('./CreateLogPreference.js');
var logger = new Logger();
And it displays:
info: The personId : 1 did a preference Action of : test on the entity Id:1 Type:truc
That's the log I want to store, but when I do a "show collections" on the database 'log', I still see nothing. How can I write this sentence in the mongoDB in the 'log' database ?
This project being recent, I don't find a lot of resources on the web.
Any clue ?
Thank you.
Best regards.
The text was updated successfully, but these errors were encountered:
Hello,
First there is a little mistake on the github publication :
var MongoDB = require('winston-mongoDB').MongoDB;
When I tried to make the module work, I saw that the require is not 'winston-mongoDB' but 'winston-mongodb'.
So, I need to make some logs of actions done by users on a website. My work is in node.js
I am trying to make working winston-mongodb to store a log (for example, a sentence) in a mongodb database
I installed mongodb on a ubuntu 10.04. Here is my source code in CoffeeScript, and in Javascript.
In CoffeeScript :
class CreateLogPreference
constructor: (personId=1, preferenceAction='test', entityType='truc', entityId=1) ->
@personid=personId
@preferenceAction=preferenceAction
@entityType=entityType
@EntityID=entityId
module.exports = CreateLogPreference;
Converted in javascript :
(function() {
var CreateLogPreference;
CreateLogPreference = (function() {
function CreateLogPreference(personId, preferenceAction, entityType, entityId) {
var MongoDB, options, winston;
if (personId == null) {
personId = 1;
}
if (preferenceAction == null) {
preferenceAction = 'test';
}
if (entityType == null) {
entityType = 'truc';
}
if (entityId == null) {
entityId = 1;
}
this.personId = personId;
this.preferenceAction = preferenceAction;
this.entityType = entityType;
this.entityId = entityId;
winston = require('winston');
winston.log('info', 'The personId : ' + this.personId + ' did a preference Action of : ' + this.preferenceAction + ' on the entity Id:' + this.entityId + ' Type:' + this.entityType);
MongoDB = require('winston-mongodb').MongoDB;
options = {
db: 'log'
};
winston.add(MongoDB, options);
}
return CreateLogPreference;
})();
module.exports = CreateLogPreference;
}).call(this);
Then I use this code :
var Logger = require('./CreateLogPreference.js');
var logger = new Logger();
And it displays:
info: The personId : 1 did a preference Action of : test on the entity Id:1 Type:truc
That's the log I want to store, but when I do a "show collections" on the database 'log', I still see nothing. How can I write this sentence in the mongoDB in the 'log' database ?
This project being recent, I don't find a lot of resources on the web.
Any clue ?
Thank you.
Best regards.
The text was updated successfully, but these errors were encountered: