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

Add logger #42

Merged
merged 15 commits into from
Oct 9, 2023
Merged

Add logger #42

merged 15 commits into from
Oct 9, 2023

Conversation

JakeRoggenbuck
Copy link
Member

@JakeRoggenbuck JakeRoggenbuck commented Oct 8, 2023

fixes #18 and fixes #19

TODO:

  • Logger in general
    - [ ] Make internal namespace This 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.
  • Convert cout calls to logger calls

Copy link
Member

@Sophon96 Sophon96 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

some comments

core/internal/logger.hpp Outdated Show resolved Hide resolved
core/meson.build Outdated Show resolved Hide resolved
core/src/logger.cpp Outdated Show resolved Hide resolved
core/src/logger.cpp Outdated Show resolved Hide resolved
enum Severity get_severity();
std::string get_message();

Log();
Copy link
Contributor

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.


public:
static Logger *Instance();
static Logger *Instance(enum Severity s);
Copy link
Contributor

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 "
Copy link
Contributor

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?

}
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");
Copy link
Contributor

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?

Copy link
Member

@Sophon96 Sophon96 left a 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)

@adamhutchings
Copy link
Contributor

Good to merge?

@JakeRoggenbuck
Copy link
Member Author

I think so!

@adamhutchings adamhutchings merged commit c1a2887 into jabacat:main Oct 9, 2023
3 checks passed
@Sophon96
Copy link
Member

Sophon96 commented Oct 9, 2023

Somehow CI passed but this PR doesn't build

@Sophon96
Copy link
Member

Sophon96 commented Oct 9, 2023

And #45 should fix it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants