Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
178 views
in Technique[技术] by (71.8m points)

string - Can you have custom @info colors?

In Julia, I have a project where I have many calculations. Next is a tiny extract of what it could look like:

[ Info: Benders Solving with subtour constraints ---  ./Instances/tiny_instance_10.txt  ---
[ Info: Spent 0.039s in Benders decomposition
[ Info: Spent 0.035s in Master problem
[ Info: Spent 0.004s in subproblem
Objective : 47.80267061445823
[ Info: 4 Optimality Constraints created
[ Info: 4 Subtour Constraints created
[ Info: MILP Creating Model ---  ./Instances/tiny_instance_10.txt  ---

I mainly use @info to output data on console. [ Info: is in teal color, which is great and I would like to know if there exists a convenient way to get other colors? That would be better to read given I have many lines with @info to print.

Something like: @info red "MyString"?

I could not find in the Julia documentation.

I believe if it is not easily makeable with @info, I will have to create my own print function?

question from:https://stackoverflow.com/questions/65832542/can-you-have-custom-info-colors

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

You could write it yourself

macro myinfo(color, what)
    quote
        printstyled($what,color=$color)
    end
end

And now:

enter image description here


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...