cyucelen / marker Goto Github PK
View Code? Open in Web Editor NEW๐๏ธ Marker is the easiest way to match and mark strings for colorful terminal outputs!
License: MIT License
๐๏ธ Marker is the easiest way to match and mark strings for colorful terminal outputs!
License: MIT License
[WIP]
Thinking about this project, it stands to reason that one of the strongest use cases would be for users to colorize their logs for easy reading. With that in mind, the current setup where you create a builder, give it a string, then mark means that there is a decent amount of overhead to integrating it with a logging system.
I was messing around with the testing
framework and the fact that the testing instances have a .Log
function got me thinking about wrapping marker in a similar way. There could be some CreateLogger
which you could pass a builder to (or maybe it is the builder) which then logs in the colorized manner you specify.
Write a simple usage documentation and example for MatchSurrounded in README.
Oftentimes in log files, the beginning of the log has certain characters encasing it ex: [INFO]
. Create a matcher which takes in surrounding characters and colorizes the encased letters, inclusive of the surrounding characters.
Create a matcher that matches days of week such as:
monday, tuesday...
or with capital first character
Monday, Tuesday..
Create a variadic Mark function that can take an arbitrary number of Matchers and colorizes the matches.
It is hard to keep the terminal pictures in README file tidy and in order with respect to size, font family, font color, background color, etc.
Want to discuss for finding a standard way that can be used by everbody to create colorful terminal output pictures for our API examples in README file.
There are some possible solutions that comes to my mind:
Create a matcher that matches e-mail addresses such as:
Given a string we need to match all valid english words that does not have numericals in them. One use case that I can think of is this feature is useful in matching all misspelled english words. For example:
"This word has a singel error"
Ouput :singel
"This word is not a word1"
No words matched here
This is branch of issue #17.
I recap the idea. We want to make wrapper for io.Writer interface, that colorize its input.
For example we want to colorize our log output. If we have this wrapper, we simply do:
log.SetOutput(NewMarkWriter(os.stdout, rules))
I've seen the PR #24 with implementation for such wrapper and I sure it works in that context (for Logger), but can have subtle bugs in others.
Writing in common can happen in parts. We can write on part of line, than - another. It's undefined how we use io.Writer and this is the reason, why it can not nicely live with Mark.
Mark have some rules, even regex and etc. It need full text to work correctly. Imagine that we writer our line in io.Writer by single byte - Mark will not work. If we match word "sense", and write:
MarkWriter.Write("se")
MarkWriter.Write("nse")
MarkWriter will not match "sense". I hope I made problem clear.
It's not like we can do nothing to mitigate this issue, but the way that I see has its own drawbacks. We can buffer and collect our line of text in MarkWriter until we get some delimiter (newline makes sense). So
MarkWriter.Write("se")
MarkWriter.Write("nse")
MarkWriter.Write(" blabla\n")
now can mark "sense", but will write entire string in it's underlying io.Writer.
And there is another thing - we should implement Close method, that will flush buffer and close underlying Writer (if it can be close of course).
Marker depends on fatih/color library to colorizing strings for terminal output. Encapsulating the colorizing behavior inside marker library to prevent multiple imports from user side can be beneficial.
I want to discuss the implementation details of this encapsulation and if its overkill and comes with restrictions along with it or not.
Since past two weeks, I feel like we built an awesome synergy among us. I really enjoyed working with you guys, I believe you all valuable and we can learn a lot from each other!
So, i want to discuss about using a platform -like Slack but without limitations- for keeping in touch. By this way, i think, we can develop marker better and faster! I believe communication channel matters for efficiency.
Even we can build new fantastic projects as a team and welcome new comers to our culture we just started to built!
Lets discuss if it is a good idea and which platform should we use.
Create a matcher which takes one of the time layouts of golang standard time library and matches them in given string.
const (
ANSIC = "Mon Jan _2 15:04:05 2006"
UnixDate = "Mon Jan _2 15:04:05 MST 2006"
RubyDate = "Mon Jan 02 15:04:05 -0700 2006"
RFC822 = "02 Jan 06 15:04 MST"
RFC822Z = "02 Jan 06 15:04 -0700" // RFC822 with numeric zone
RFC850 = "Monday, 02-Jan-06 15:04:05 MST"
RFC1123 = "Mon, 02 Jan 2006 15:04:05 MST"
RFC1123Z = "Mon, 02 Jan 2006 15:04:05 -0700" // RFC1123 with numeric zone
RFC3339 = "2006-01-02T15:04:05Z07:00"
RFC3339Nano = "2006-01-02T15:04:05.999999999Z07:00"
Kitchen = "3:04PM"
// Handy time stamps.
Stamp = "Jan _2 15:04:05"
StampMilli = "Jan _2 15:04:05.000"
StampMicro = "Jan _2 15:04:05.000000"
StampNano = "Jan _2 15:04:05.000000000"
)
An example:
strWithTimestamp := "Current timestamp is 2019-10-07T23:45:05Z03:00"
match := MatchTimestamp(time.RFC3339)(strWithTimestamp)
// expected match => Match{Template: "Current timestamp is %s", Patterns: []string{"2019-10-07T23:45:05Z03:00"}}
Distinct implementations can be written for each format. We can discuss to split the issue to fine grained pieces on the way with respect to complexity.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.