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

Crayons do not work with line breaks and with the standard Julia logging. #26

Open
dmitry-v-vlasov opened this issue Feb 2, 2019 · 2 comments

Comments

@dmitry-v-vlasov
Copy link

dmitry-v-vlasov commented Feb 2, 2019

using Crayons.Box
@info LIGHT_GRAY_FG("Hello,\nUniverse!")

image

@ghjwp7
Copy link

ghjwp7 commented Jan 20, 2022

Maybe this issue should be closed, as it isn't a Crayons issue. It probably is a Julia-print-system issue or a logging.jl issue that could be mentioned in Crayons docs.

To see it isn't a Crayons issue, note that while 'Hello' printed ok in gray foreground, the at the beginning of the second line switched to cyan color. That is, the print-system or logging applied a color change that ignored and overrode the previous setting. Instead of changing back to previous color after that, the print-system or logging apparently set a default color.

I don't see any color changes in logging.jl and don't know where the cyan or green colors were set. In 1.7.0-rc2 REPL on my Linux system, white is the default color instead of green. Running your test code in a program file has the same result as in REPL.

A workaround might be to store the desired Crayon setup in a variable or function C, and reapply it after a \n. Eg, @info C("Hello,\n"), C("Universe!") or @info "$(C)Hello,\n$(C)Universe!". I'm not sure if the latter is feasible and don't know whether Crayons stores the current state aside from user-initiated stacking. I think it isn't able to detect from scratch what the state is.

@czylabsonasa
Copy link

czylabsonasa commented Jan 7, 2023

as a quick & dirty workaround i would define a function that takes a Crayon c and a message String m and apply c for each of the "rows" of m:

image

(rdrw stands for redefine row wise :-) )

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

No branches or pull requests

3 participants