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

Logs include color-changing ASCII codes even when logs are disabled #104

Closed
henricasanova opened this issue May 15, 2019 · 6 comments
Closed
Assignees
Labels
Milestone

Comments

@henricasanova
Copy link
Contributor

No description provided.

@henricasanova henricasanova added this to the 1.5 milestone May 15, 2019
@henricasanova henricasanova self-assigned this May 15, 2019
@henricasanova
Copy link
Contributor Author

fixed.

@ryantanaka
Copy link
Member

hey @henricasanova, so this issue refers to 5e840ff right?

In one of my activities, I run wrench like this:

CMD ./simulator_remote_storage 10 \
         --log="root.fmt:[%d][%h:%t]%e%m%n" \
         --log=root.thresh:critical \
         --log=wms.thresh:debug \
         --log=simple_wms.thresh:debug \
         --log=simple_wms_scheduler.thresh:debug

And I get no color. But, running ./simulator_remote_storage 10, I do get color in the terminal.

In the following functions, when I remove the nots, then I get the correct color always.

/**
* @brief Turn on colored output for the calling process
*/
void TerminalOutput::beginThisProcessColor() {
if ((not TerminalOutput::wrench_no_log) and (TerminalOutput::color_enabled)) {
std::cerr << TerminalOutput::getThisProcessLoggingColor();
}
}
/**
* @brief Turn off colored output for the calling process
*/
void TerminalOutput::endThisProcessColor() {
if ((not TerminalOutput::wrench_no_log) and (TerminalOutput::color_enabled)) {
std::cerr << "\033[0m";
}
}

I want to make sure that change won't break anything else since I don't have any context for this issue.

Thanks!

@ryantanaka ryantanaka reopened this Jun 3, 2019
@henricasanova
Copy link
Contributor Author

Let me investigate.... seems that colors are broken a bit.

@henricasanova
Copy link
Contributor Author

Just pushed a fix. Let me know if it addresses your bug.

@ryantanaka
Copy link
Member

ok thanks, it works now

@henricasanova
Copy link
Contributor Author

henricasanova commented Jun 19, 2019

Reopened this issue because there is still a problem. The WRENCH logging is just a few macros above the XBT logging. For instance, WRENCH_INFO does:

  • If colors are enabled, insert the "begin color" ASCII codes
  • call XBT_INFO
  • If colors are enabled, insert the "end color" ASCII codes

The problem is that if the user disables an xbt log category, the above still does steps #1 and #3. And the xbt log API does not provide an "am I enabled?" or "what's my priority?" API (it does have such functions, but they required the category name).

Henri will think of a solution.

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

No branches or pull requests

2 participants