-
Notifications
You must be signed in to change notification settings - Fork 5
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
Add logger #42
Add logger #42
Conversation
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.
some comments
Co-authored-by: Brandon Qi <[email protected]>
Co-authored-by: Brandon Qi <[email protected]>
core/internal/logger.hpp
Outdated
enum Severity get_severity(); | ||
std::string get_message(); | ||
|
||
Log(); |
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 just remembered that you can do default parameters just like in Python rather than overloading, so we should probably do that instead.
core/internal/logger.hpp
Outdated
|
||
public: | ||
static Logger *Instance(); | ||
static Logger *Instance(enum Severity s); |
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.
Same thing down here.
} | ||
|
||
std::unique_ptr<Vector> Matrix::multiply(std::unique_ptr<Vector> in) { | ||
|
||
if (in->get_size() != this->n) { | ||
std::cout << "Tried to multiply a vector of size " << in->get_size() | ||
<< " with a matrix containing " << this->n << " columns." << std::endl; | ||
LOGGER->log(Log(WARN) << "Tried to multiply a vector of size " |
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.
Is this a warning? It seems like an error. (Also with the one for vectors below). What do you think?
core/src/math/vector.cpp
Outdated
} | ||
this->entries[pos] = val; | ||
} | ||
|
||
void Vector::add_entry(int pos, double val) { | ||
if (pos < 0 || pos >= this->length) { | ||
std::cout << "Position " << pos << " out of bounds." << std::endl; | ||
LOGGER->log(Log(WARN) << "Position " << pos << " out of bounds.\n"); |
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 is this a WARN
when the other two are ERR
?
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.
This API is a bit unconventional, but feel free to merge this (I'll be offline most of today)
Good to merge? |
I think so! |
Somehow CI passed but this PR doesn't build |
And #45 should fix it. |
fixes #18 and fixes #19
TODO:
- [ ] Make internal namespaceThis would mean that Log would have to be internal::log and WARN would have to be internal::WARN, which is a lot to just log. I'm not sure if this should be done.