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

Adjust LogSink log formatter #5037

Closed
jmarrec opened this issue Nov 14, 2023 · 2 comments · Fixed by #5042
Closed

Adjust LogSink log formatter #5037

jmarrec opened this issue Nov 14, 2023 · 2 comments · Fixed by #5042

Comments

@jmarrec
Copy link
Collaborator

jmarrec commented Nov 14, 2023

Issue overview

Prompted by the fact that the run.log looks quite different between the classic (Ruby) and the C++ CLI.

Additionally, the default formatter is not great. The use of Integers for the log level is unnecessarily confusing. I think I know how to turn the LogLevel enum into a string (eg: "Debug" instead of -1)

// set formatting, seems like you have to call this after the stream is added
// DLM@20110701: would like to format Severity as string but can't figure out how to do it
// because you can't overload operator<< for an enum type
// this seems to suggest this should work: http://www.edm2.com/0405/enumeration.html
m_sink->set_formatter(expr::stream << "[" << expr::attr<LogChannel>("Channel") << "] <" << expr::attr<LogLevel>("Severity") << "> "
<< expr::smessage);

Current Behavior

C++

[openstudio.measure.OSRunner] <0> runner.registerWarning called
[openstudio.workflow.OSWorkflow] <0> No results for objective function IsNonExisting.NonExisting

Ruby:

[13:54:18.023960 WARN] runner.registerWarning called
[13:54:18.056100 WARN] No results for objective function IsNonExisting.NonExisting

Expected Behavior

Steps to Reproduce

Possible Solution

Details

Environment

Some additional details about your environment for this issue (if relevant):

  • Platform (Operating system, version):
  • Version of OpenStudio (if using an intermediate build, include SHA):

Context

@jmarrec
Copy link
Collaborator Author

jmarrec commented Nov 15, 2023

Given this call: LOG_FREE(Debug, "Channel", "MSG")

Current behavior:

# C++
[Channel] <-1> MSG
# Ruby's run.log
[11:12:13.123456 DEBUG] MSG

Proposed, when running a workflow:

# Proposed
# Stdout
[Channel] <Debug> MSG
# run.log
[11:12:13.123456 DEBUG] [Channel] MSG

Additional question: do we need a switch to use the old run.log format or just set the behavior?

thoughts please?

@kbenne
Copy link
Contributor

kbenne commented Nov 15, 2023

I like the proposed format [11:12:13.123456 DEBUG] [Channel] MSG without a switch. Would that be ok for everyone? @shorowit @joseph-robertson

kbenne added a commit that referenced this issue Nov 15, 2023
Fix #5037 - Adjust log formatters for workflow (stdout + run.log)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants