-
Notifications
You must be signed in to change notification settings - Fork 1
Rework logging #22
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
Rework logging #22
Conversation
|
@panmari : What are your thoughts on this change? Is this rather confusing or does it indeed reduce the overall pollution? Personally, I make use of these log-method quiet often (when debugging code via |
| class MeshTriangle; | ||
| class MeshData; | ||
|
|
||
| class Logger { |
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.
the final idea is to make this a singleton class. Currently, this is stateless. Later, this class could however store the path to its log file (or even an output stream).
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.
I like it! Having logging code in one place makes sense to me.
| nb.log(); | ||
| nc.log(); | ||
| } | ||
| Vector3f getNormalA() const { return na; } |
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.
I guess we could omit these getter-method and simply expose na, nb and nc since there are immutable (marked by const), then again this could produce an inconsistent api. One might assume that are getters. Dunno what makes sense the most. Any suggestions @panmari ?
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.
Whatever your preferred style is. Be aware that this is more than a getter though: It makes a copy of na.
c357fdd to
34596c1
Compare
|
|
||
| TEST(Logger, log_ray) { | ||
| Ray ray(new Vector3f(), new Vector3f()); | ||
| Logger().log(ray); |
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.
To make this better testable, you could split the method into string conversion/actual logging, i.e:
ToString(MeshTriangle&) {
}
template
Log(const Loggable& l) {
std::out << ToString(l);
}
This patch moves all log-methods to a common place. The idea of this patch is to reduce the pollution of classes.