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

build heroku style log coloring into the papertrail-cli #51

Open
diwu1989 opened this issue May 22, 2015 · 3 comments
Open

build heroku style log coloring into the papertrail-cli #51

diwu1989 opened this issue May 22, 2015 · 3 comments

Comments

@diwu1989
Copy link

the colortail command and sample file doesn't color the log the same way heroku papertrail does it.

you really should just build the color functionality into papertrail-cli

@troy
Copy link
Contributor

troy commented May 22, 2015

Yeah, I agree. I find myself using the heroku logs more than I should, purely because of the color. I think what it does is the minimum.

Can you think of ways we can improve upon what heroku logs (in a buildpack-agnostic way)? For example, would you prefer if the colorization was based on dyno ID as well as dyno type? Something else?

@troy troy self-assigned this May 22, 2015
@troy troy removed their assignment Jun 17, 2015
@troy
Copy link
Contributor

troy commented Sep 25, 2015

More implementation notes:

  • goal is to consistently colorize timestamp, hostname, and program/filename, using a color chosen from among a palette of 5 which are visible on both black and white backgrounds. The colors are here, excluding black, white, and blue (hard to distinguish from cyan)
  • color should be chosen based on the hostname+program pair, then used for all logs from that hostname+program throughout at least that 1 invocation. >1 hostname+program pairs may have the same color, since there will often be far more than 5 hostname+program pairs. For now and probably for release, feel free to use something like (hostname.length + program.length) % 5 as the index to a colors array
  • colorize portion of output from start of line up to and including the : prior to the start of the message. Example portion of output which would be colorized: Sep 25 16:13:15 www23 app/web.2:
  • probably using something like the ansi gem.
  • here's Heroku's implementation, which is the inspiration for this behavior but operates on only the program/filename.

@troy
Copy link
Contributor

troy commented Sep 25, 2015

Also:

  • honor this to decide whether to enable/disable it
  • papertrail-cli is licensed under the MIT License, as is heroku-cli, so if any or all of that log displayer class is reusable, feel free to do so

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

No branches or pull requests

2 participants