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

Create an AnsiTemplater class, to add ANSI markup to input #2

Open
dimo414 opened this issue Feb 9, 2016 · 1 comment
Open

Create an AnsiTemplater class, to add ANSI markup to input #2

dimo414 opened this issue Feb 9, 2016 · 1 comment

Comments

@dimo414
Copy link
Owner

dimo414 commented Feb 9, 2016

Original report by Michael Diamond (Bitbucket: dimo414).


E.g. colorize ERROR/WARNING log lines.

@dimo414
Copy link
Owner Author

dimo414 commented Apr 13, 2016

Original comment by Michael Diamond (Bitbucket: dimo414).


Potential syntax:

AnsiTemplater template = AnsiTemplater.builder()
  // Color lines containing "ERROR" red
  .addTemplate().color(RED).pattern(".*ERROR.*")
  // Color the word OK green when surrounded by square brackets (like [ OK ] service messages)
  .addTemplate().string("[ ").color(GREEN).string("OK").string(" ]")
  // highlight the word foo wherever it appears
  .addTemplate().color(YELLOW, BOLD).caseInsensitiveString("foo")
  .build();

template.process(System.in).toOut();
template.process(Paths.get(filename)).toErr();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant