cyucelen / marker

🖍️ Marker is the easiest way to match and mark strings for colorful terminal outputs!
MIT License
47 stars 13 forks source link

[WIP] Log marker #24

Closed cyucelen closed 4 years ago

cyucelen commented 4 years ago

It stands to reason that one of the strongest use cases would be for users to colorize their logs for easy reading.

We can add further features to the checklist!

Closes #17

codecov-io commented 4 years ago

Codecov Report

Merging #24 into master will decrease coverage by 1.62%. The diff coverage is 88.23%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #24      +/-   ##
==========================================
- Coverage     100%   98.37%   -1.63%     
==========================================
  Files           3        4       +1     
  Lines         106      123      +17     
==========================================
+ Hits          106      121      +15     
- Misses          0        1       +1     
- Partials        0        1       +1
Impacted Files Coverage Δ
log.go 88.23% <88.23%> (ø)
matcher.go 100% <0%> (ø) :arrow_up:

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 03dc5bf...70b11f8. Read the comment docs.

cyucelen commented 4 years ago

Do we need to create a variadic AddRule method? What do you think about its usefulness?

Darkclainer commented 4 years ago

I think it should be another PR. See issue #27.

cyucelen commented 4 years ago

What should be another PR? Buffering writer output until \n?

jnatalzia commented 4 years ago

Re: Variadic method

For the first pass I feel like the slice approach is good enough but if it's not a huge ordeal we might as well put it in this PR. What do you think the LoE is?

cyucelen commented 4 years ago

Oh, we need to test the rule apply order by the way. Since we are applying the rules sequentially, some matches can overlap - later order matcher will override the previous ones if there is an overlap.

Users need to be aware of it and add their mark rules according to the order too. We need to document this and give an example for it too.

cyucelen commented 4 years ago

Re: Variadic method

For the first pass I feel like the slice approach is good enough but if it's not a huge ordeal we might as well put it in this PR. What do you think the LoE is?

I don't know what LoE is :smile: but we can skip it for now, less is more!

cyucelen commented 4 years ago

Implemented some helper functionality for our assertions in assert.go and tested mark rules with it. Can you check it out? Then we can resolve the corresponding reviews.

Darkclainer commented 4 years ago

You can not compare function. See https://stackoverflow.com/questions/42140758/collection-of-unique-functions-in-go/42147285#42147285

cyucelen commented 4 years ago

You can not compare function. See https://stackoverflow.com/questions/42140758/collection-of-unique-functions-in-go/42147285#42147285

This approach actually looks like working. I tested it for our MatcherFunc type and it fails when MatcherFuncs actually not equal.

Darkclainer commented 4 years ago

This behaviour is implementation defined.

cyucelen commented 4 years ago

This behaviour is implementation defined.

You mean undefined?

Darkclainer commented 4 years ago

No. Current standard says that functions are incomparable, see https://golang.org/ref/spec#Comparison_operators . Using reflect in that particular case, with current go implementation you got desired behavior.

cyucelen commented 4 years ago

I get it.

This behavior is not specified and so, can vary between different compiler implementations. Here is the question; is it really a big problem for us?

I prefer the second way if the tests for the first option will impact the implementation and make it more complex.

Darkclainer commented 4 years ago

I think second option is fine, but you should come up with test that cover order of rules too.

cyucelen commented 4 years ago

Aye aye, captain!

jnatalzia commented 4 years ago

@cyucelen is it just the readme docs that remain for this feature? super excited to integrate it into some projects

cyucelen commented 4 years ago

@jnatalzia yes, can you help about docs?

jnatalzia commented 4 years ago

Can do!

jnatalzia commented 4 years ago

Docs added! Also refactored a small portion of the code, added a comment explaining what and why to the PR

cyucelen commented 4 years ago

We merged the @Darkclainer s unified image PR to master. Can you integrate it to this branch? I will review your last commit about Writer asap!

jnatalzia commented 4 years ago

Yes I can! Also seems like I need to add some code coverage, gotta love CI. Will fix it up today at some point

codecov-io commented 4 years ago

Codecov Report

Merging #24 into master will not change coverage. The diff coverage is 100%.

Impacted file tree graph

@@          Coverage Diff          @@
##           master    #24   +/-   ##
=====================================
  Coverage     100%   100%           
=====================================
  Files           3      4    +1     
  Lines         106    121   +15     
=====================================
+ Hits          106    121   +15
Impacted Files Coverage Δ
log.go 100% <100%> (ø)

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 03dc5bf...71e4d90. Read the comment docs.

jnatalzia commented 4 years ago

Hmmm @Darkclainer can we make an issue/PR to update the docs for using the image generator? It requires a pip install (maybe foreign for a go repo) as well as two separate terminal dependencies but no indication of where to get them. I can guess but given I'm installing them in the shell, I'd prefer to have sanctioned sources

cc @cyucelen

cyucelen commented 4 years ago

Awesome PR @jnatalzia!

I just added some docs for image_generator, also updated the images of log feature in readme.

Maybe we can get rid of functional options in WriteMarker since we are not using it anymore ?

Looks like we are getting ready for the deployment! :sunglasses:

Also, what do you think about #29 ? @jnatalzia @Darkclainer

jnatalzia commented 4 years ago

Maybe we can get rid of functional options in WriteMarker since we are not using it anymore ?

Sounds like a plan! Will push an update with those removed and then I think we're good to merge. Will mark as no longer draft.

Will comment on #29 on the issue!

cyucelen commented 4 years ago

Looks like we are good to go! Do the final touch, merge it!