Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX] Fix Logger stdout publication #6682

Merged
merged 1 commit into from
Apr 13, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 11 additions & 8 deletions packages/rocketchat-logger/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -323,29 +323,32 @@ SystemLogger = new Logger('System', { // eslint-disable-line no-undef
});


class StdOut extends EventEmitter {
const StdOut = new class extends EventEmitter {
constructor() {
super();
const write = process.stdout.write;
this.queue = [];
process.stdout.write = (string) => {
write.apply(process.stdout, arguments);
process.stdout.write = (...args) => {
write.apply(process.stdout, args);
const date = new Date;
string = processString(string, date);
const string = processString(args[0], date);
const item = {
id: Random.id(),
string,
ts: date
};
this.queue.push(item);
const limit = RocketChat.settings.get('Log_View_Limit');
if (limit && this.queue.length > limit) {
this.queue.shift();

if (typeof RocketChat !== 'undefined') {
const limit = RocketChat.settings.get('Log_View_Limit');
if (limit && this.queue.length > limit) {
this.queue.shift();
}
}
this.emit('write', string, item);
};
}
}
};


Meteor.publish('stdout', function() {
Expand Down