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
Define which message types should not be logged #2022
Conversation
src/models/msg.js
Outdated
Msg.NonLoggableTypes = {}; | ||
Msg.NonLoggableTypes[Msg.Type.BANLIST] = true; | ||
Msg.NonLoggableTypes[Msg.Type.MOTD] = true; | ||
Msg.NonLoggableTypes[Msg.Type.WHOIS] = true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Msg.NonLoggableTypes = { [Msg.Type.BANLIST]: true, ...}
maybe?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doesn't work on node 4 afaik.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$ nvm use 4
Now using node v4.8.4 (npm v2.15.11)
$ node
> a = 42
42
> { [a]: 1}
{ '42': 1 }
🤷♂️
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not add a method to the Msg
class instead that would do:
function isLoggable() {
return this.type !== Msg.Type.MOTD &&
this.type !== Msg.Type.BANLIST &&
this.type !== Msg.Type.WHOIS;
}
And in writeUserLog
:
if (!msg.isLoggable()) {
return false;
}
It seems more idiomatic to me, no?
(I went for isLoggable
and not isNotLoggable
because it's fairly common practice to avoid negated boolean functions)
Bonus, you can get rid of const Msg = require("./msg");
😁
src/models/msg.js
Outdated
Msg.NonLoggableTypes = {}; | ||
Msg.NonLoggableTypes[Msg.Type.BANLIST] = true; | ||
Msg.NonLoggableTypes[Msg.Type.MOTD] = true; | ||
Msg.NonLoggableTypes[Msg.Type.WHOIS] = true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$ nvm use 4
Now using node v4.8.4 (npm v2.15.11)
$ node
> a = 42
42
> { [a]: 1}
{ '42': 1 }
🤷♂️
src/models/msg.js
Outdated
Msg.NonLoggableTypes = {}; | ||
Msg.NonLoggableTypes[Msg.Type.BANLIST] = true; | ||
Msg.NonLoggableTypes[Msg.Type.MOTD] = true; | ||
Msg.NonLoggableTypes[Msg.Type.WHOIS] = true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not add a method to the Msg
class instead that would do:
function isLoggable() {
return this.type !== Msg.Type.MOTD &&
this.type !== Msg.Type.BANLIST &&
this.type !== Msg.Type.WHOIS;
}
And in writeUserLog
:
if (!msg.isLoggable()) {
return false;
}
It seems more idiomatic to me, no?
(I went for isLoggable
and not isNotLoggable
because it's fairly common practice to avoid negated boolean functions)
Bonus, you can get rid of const Msg = require("./msg");
😁
a2027fa
to
1fdd1ff
Compare
Changed it to what @astorije suggested. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, much nicer.
whois
log is currently logged asundefined whois
which isn't at all useful.