Skip to content

Change color acording to the level#980

Closed
shargon wants to merge 4 commits intoneo-project:masterfrom
shargon:style-log
Closed

Change color acording to the level#980
shargon wants to merge 4 commits intoneo-project:masterfrom
shargon:style-log

Conversation

@shargon
Copy link
Copy Markdown
Member

@shargon shargon commented Aug 1, 2019

image

@shargon shargon requested a review from erikzhang August 1, 2019 10:44
@codecov-io
Copy link
Copy Markdown

Codecov Report

Merging #980 into master will increase coverage by 0.05%.
The diff coverage is 83.33%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #980      +/-   ##
==========================================
+ Coverage   53.77%   53.83%   +0.05%     
==========================================
  Files         194      195       +1     
  Lines       13251    13275      +24     
==========================================
+ Hits         7126     7146      +20     
- Misses       6125     6129       +4
Impacted Files Coverage Δ
neo/ConsoleColorSet.cs 100% <100%> (ø)
neo/Consensus/ConsensusService.cs 16.48% <50%> (+0.59%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update f927dec...9339a18. Read the comment docs.

Copy link
Copy Markdown
Member

@vncoelho vncoelho left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@shargon, nice template.

Maybe this could be out of Consensus, we could use the same template for P2P debug.

EDITED: It was already out...sorry. I just realized it now.

@shargon
Copy link
Copy Markdown
Member Author

shargon commented Aug 1, 2019

We should define the colors, feel free to change it

@vncoelho
Copy link
Copy Markdown
Member

vncoelho commented Aug 1, 2019

Looks good to me, @shargon. You are an artist.

Console.WriteLine($"[{DateTime.Now.TimeOfDay:hh\\:mm\\:ss\\.fff}] {message}");
Plugin.Log(nameof(ConsensusService), level, message);

currentColor.Apply();
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@shargon, this way all the time we are going to set the log? In every message?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to back to the previous color

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Onh man...But there is an other solution @igormcoelho

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is good Vitor... it's just stream set/unset, it's bullet fast.

@vncoelho vncoelho requested a review from igormcoelho August 1, 2019 11:34

private void Log(string message, LogLevel level = LogLevel.Info)
{
var currentColor = new ConsoleColorSet();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only thing I don't like here is this Dynamic memory criation for object... couldn't this all be static? it's such a simple thing...

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you want, we could store the initial color in a static var

Copy link
Copy Markdown
Contributor

@igormcoelho igormcoelho left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

move to static

@shargon
Copy link
Copy Markdown
Member Author

shargon commented Aug 1, 2019

@igormcoelho When Log is called, you can be writing a password (Yellow), or it could be listing your addresses (White), both colors are different, so what is your proposal for the static var?

@igormcoelho
Copy link
Copy Markdown
Contributor

I mean, instead of creating a new ColorObject for every log, you could just invoke static coloring methods, no?

igormcoelho
igormcoelho previously approved these changes Aug 1, 2019
Copy link
Copy Markdown
Contributor

@igormcoelho igormcoelho left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, now I got the need for going back to previous color...
Just beware that perhaps multi-threading here may mix all colors, I don't know if it may happen.

@erikzhang
Copy link
Copy Markdown
Member

Can we move this to a plugin?

@shargon
Copy link
Copy Markdown
Member Author

shargon commented Aug 2, 2019

I think that the logic affected is here, in ConsensusService.Log

@erikzhang
Copy link
Copy Markdown
Member

I mean, move all the log related stuff to the plugin.

@shargon
Copy link
Copy Markdown
Member Author

shargon commented Aug 2, 2019

Take a look at neo-project/neo-modules#112, i will change this for remove the Console.Write

@shargon
Copy link
Copy Markdown
Member Author

shargon commented Aug 2, 2019

Problems with CRLF

@shargon shargon closed this Aug 2, 2019
@erikzhang erikzhang deleted the style-log branch August 2, 2019 10:27
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

Successfully merging this pull request may close these issues.

5 participants