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

Log printing tweaks #25488

Merged
merged 1 commit into from
Jan 11, 2018
Merged

Log printing tweaks #25488

merged 1 commit into from
Jan 11, 2018

Conversation

c42f
Copy link
Member

@c42f c42f commented Jan 10, 2018

In response to various feedback about the log formatting (particularly the metadata placement) in #25370 and on slack, here's yet another iteration at finding a generally agreeable format. Notes:

  • There was no general agreement on right justification of metadata so I've provided a way to customize this and set it to right justify to 100 columns by default. This solves the problem of wide terminals, but doesn't solve some general gripes about this feature existing! I've been flip flopping between setting it to zero columns by default vs setting it to something nonzero (my preferred option).
  • To make the formatting more compact, I've put the metadata on the same line as the last line of the message / keyword printing. This also makes the single and multi line formats more similar.
  • I experimented with turning off the metadata printing completely for Info. I thought the inconsistency was a little confusing, so it's back on again for now. It's easy to experiment with this by using your own meta_formatter function.
  • I've added color customization to the metadata formatting function so this can now be overridden more cleanly. It still uses the environment variables JULIA_INFO_COLOR etc for now, but this could arguably be removed.
  • I've cleaned up the tests significantly.

@c42f
Copy link
Member Author

c42f commented Jan 10, 2018

Example pictures

Current default format (justify metadata to 100 columns, or to right of terminal whichever is smaller)
metadata_tweaks

Right justification disabled completely:
metadata_no_justify

Metadata for Info level removed:
metadata_no_infometa

@c42f c42f added the logging The logging framework label Jan 10, 2018
@KristofferC
Copy link
Member

+1 for no metadata for @info(I don't think I ever wanted someone to know exactly where I emitted an info message to show in the REPL) and +1 for putting the metadata back on its own line on multiline output. It looks quite off where it is now in e.g. the matrix and stacktrace examples.

@StefanKarpinski
Copy link
Member

Fully agree with @KristofferC on both of those points: no metadata for @info; metadata on its own line for multiline outputs. I would also favor the version of error/warn output with metadata on the left since for those log types you the metadata is relatively important. That also addresses the "wide terminal" problem, which I find picking an arbitrary "max width" to be a hacky solution to at best.

@c42f
Copy link
Member Author

c42f commented Jan 11, 2018

Thanks for the comments. I'm relieved that these tweaks turned out to be easy to try with the newly refactored code. Before I go and update the tests again, here's some screenshots.

First, here's the style I think you're asking for as the default. Having removed the metadata for Info, I think this strikes is a pretty good compromise of minimal but informative.
no_justify_default

I agree that the way the right justification worked wasn't that visually pleasing for intermediate widths. I've made that a bit nicer now; here's a couple of other styles which can be achieved by setting the right_justify to something nonzero:

The version I prefer (being personally a user of tall narrow terminals):
justify_right

For users of wide terminals, the right justification can be controlled. I'm not sure that's super useful, but it's basically a side effect of supporting the two styles above, so I'm inclined to leave it in.
justify_100

@StefanKarpinski
Copy link
Member

StefanKarpinski commented Jan 11, 2018

I really like the first style that you said I was asking for as a default. It has a certain feel of "ah, yes, that's just right" (to me at least). With metadata not printed in info messages, it really works. I think the extra line on warnings, errors and debug message is totally ok and actually visually helpful to pick them out. If anyone has real need for their debug or warning message to be very compact, I think using a custom logger format would be ok.

@KristofferC
Copy link
Member

Yes, first one is great!

@c42f c42f force-pushed the cjf/ConsoleLogger-formatting branch from 6e59eca to f5a3e6e Compare January 11, 2018 09:57
The metadata suffix is now printed on its own line by default, and
disabled for `Info` level logging.  The printing can be made more
compact if desired by right justifying the metadata using the
`right_justify` setting.

Color is made customizable by requiring that it's returned from the
meta_formatter() function.
@c42f c42f force-pushed the cjf/ConsoleLogger-formatting branch from f5a3e6e to 52c4c45 Compare January 11, 2018 10:50
@c42f
Copy link
Member Author

c42f commented Jan 11, 2018

Great, I've pushed an update which makes that the default. Let's see what CI says.

@StefanKarpinski
Copy link
Member

StefanKarpinski commented Jan 11, 2018

CI likes it too! (As well as CI likes anything these days 😝)

@StefanKarpinski StefanKarpinski merged commit cbae7a2 into master Jan 11, 2018
@StefanKarpinski StefanKarpinski deleted the cjf/ConsoleLogger-formatting branch January 11, 2018 17:26
@StefanKarpinski
Copy link
Member

Love it!

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

Successfully merging this pull request may close these issues.

3 participants