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

Replace logger #955

Merged
merged 17 commits into from
May 12, 2020
Merged

Replace logger #955

merged 17 commits into from
May 12, 2020

Conversation

jdahm
Copy link
Contributor

@jdahm jdahm commented May 7, 2020

Technical Description

Replace Logger by a similar but improved infrastructure.

A follow-up PR will replace the diagnostics with this.

The Logger design is similar to before, however there are separate loggers dawn::log::info, dawn::log::warning, and dawn::log::error which are globals similar to std::cout and std::cerr.

Each logger has an LoggerProxy operator()(string, int) as before that returns the stream operator

Each logger also acts as a container that stores the messages (a la DiagnosticsEngine).

Instead of a virtual LoggerInterface that potentially leaks memory when registering other class instance pointers, this is replaced with a lightweight std::function object Logger::Formatter, so GTClang and other frameworks can register their own message formatting.

Loggers also take underlying std::ostreams, which can be customized to write to strings, files, etc.

Resolves / Enhances

Part of #950.

Testing

Integrates into ctest.

@jdahm jdahm mentioned this pull request May 7, 2020
@jdahm jdahm requested review from havogt and twicki May 8, 2020 02:37
@jdahm
Copy link
Contributor Author

jdahm commented May 8, 2020

launch jenkins

@jdahm
Copy link
Contributor Author

jdahm commented May 8, 2020

launch jenkins

@jdahm
Copy link
Contributor Author

jdahm commented May 8, 2020

launch jenkins

@jdahm jdahm marked this pull request as draft May 8, 2020 19:10
@jdahm jdahm marked this pull request as ready for review May 8, 2020 19:47
@jdahm
Copy link
Contributor Author

jdahm commented May 8, 2020

launch jenkins

@jdahm
Copy link
Contributor Author

jdahm commented May 8, 2020

launch jenkins

@@ -234,8 +234,8 @@ bool PassRemoveScalars::run(
// Check if we have unsupported statements. If we do, warn the user and skip the pass execution.
for(const auto& stmt : iterateIIROverStmt(*stencilInstantiation->getIIR())) {
if(isStatementUnsupported(stmt, stencilInstantiation->getMetaData())) {
DAWN_LOG(INFO) << "Unsupported statement at line " << stmt->getSourceLocation()
<< ". Skipping removal of scalar variables.";
DAWN_DIAG(INFO, stencilInstantiation->getMetaData().getFileName(), stmt->getSourceLocation())
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Here is an example of the diagnostic in code.

Copy link
Contributor

Choose a reason for hiding this comment

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

is the idea to not switch in this but in a follow up PR?

std::cout << "PASS: " << getName() << ": " << stencilInstantiation->getName()
<< ": DoMethod: " << doMethod->getID() << " removed variable: " << varName
<< std::endl;
DAWN_LOG(INFO) << stencilInstantiation->getName() << ": DoMethod: " << doMethod->getID()
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Switched to DAWN_LOG(INFO) instead.

Copy link
Contributor

Choose a reason for hiding this comment

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

👍

break;
case google::protobuf::LOGLEVEL_FATAL:
DAWN_LOG(FATAL) << "Protobuf: " << message;
throw SyntacticError(std::string("[FATAL] Protobuf error occurred: ") + message);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This should match the other error before merging.

@jdahm
Copy link
Contributor Author

jdahm commented May 8, 2020

launch jenkins

Copy link
Contributor

@twicki twicki left a comment

Choose a reason for hiding this comment

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

looks great

std::cout << "PASS: " << getName() << ": " << stencilInstantiation->getName()
<< ": DoMethod: " << doMethod->getID() << " removed variable: " << varName
<< std::endl;
DAWN_LOG(INFO) << stencilInstantiation->getName() << ": DoMethod: " << doMethod->getID()
Copy link
Contributor

Choose a reason for hiding this comment

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

👍

@@ -234,8 +234,8 @@ bool PassRemoveScalars::run(
// Check if we have unsupported statements. If we do, warn the user and skip the pass execution.
for(const auto& stmt : iterateIIROverStmt(*stencilInstantiation->getIIR())) {
if(isStatementUnsupported(stmt, stencilInstantiation->getMetaData())) {
DAWN_LOG(INFO) << "Unsupported statement at line " << stmt->getSourceLocation()
<< ". Skipping removal of scalar variables.";
DAWN_DIAG(INFO, stencilInstantiation->getMetaData().getFileName(), stmt->getSourceLocation())
Copy link
Contributor

Choose a reason for hiding this comment

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

is the idea to not switch in this but in a follow up PR?

@jdahm jdahm merged commit e06dcfd into MeteoSwiss-APN:master May 12, 2020
@jdahm jdahm deleted the replace_logger branch May 12, 2020 19:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants