Skip to content
This repository has been archived by the owner on Nov 20, 2020. It is now read-only.

Logs with colors #20

Closed
zbbfufu opened this issue Feb 29, 2016 · 4 comments
Closed

Logs with colors #20

zbbfufu opened this issue Feb 29, 2016 · 4 comments
Assignees

Comments

@zbbfufu
Copy link

zbbfufu commented Feb 29, 2016

Hello,
Nice project 👍

Should it be possible to 'prettify' logs ?
Especially ansi colors codes (https://en.wikipedia.org/wiki/ANSI_escape_code#Colors).

Here a sample nginx logs output from your log endpoint /api/v1/logs/:id/:container/:limit

"2016-02-29T10:25 \u001b[0;37;1mforego | \u001b[0mstarting nginx.1 on port 5000",
"2016-02-29T10:25 \u001b[0;37;1mforego | \u001b[0mstarting dockergen.1 on port 5100",
"2016-02-29T10:25 \u001b[0;33;1mdockergen.1 | \u001b[0;31;1m2016/02/29 10:25:31 Generated '/etc/nginx/conf.d/default.conf' from 4 containers",
"2016-02-29T10:25 \u001b[0m\u001b[0;33;1mdockergen.1 | \u001b[0;31;1m2016/02/29 10:25:31 Running 'nginx -s reload'",
"2016-02-29T10:25 \u001b[0m\u001b[0;33;1mdockergen.1 | \u001b[0;31;1m2016/02/29 10:25:32 Watching docker events",

Here "\u001b[0;36;1mnginx.1 | \u001b[0m" should display "nginx.1 | " in cyan (36) and bold (1).

You may use https://github.com/ralphbean/ansi2html in Python or https://github.com/rburns/ansi-to-html in Javascript.

Regards
Julien

@francescou
Copy link
Owner

Hello Julien,

thanks for the suggestion, I'll do some investigation about this, I could add this feature in the upcoming 1.0 release

@francescou francescou self-assigned this Mar 8, 2016
francescou added a commit that referenced this issue Mar 8, 2016
@francescou
Copy link
Owner

Hello Julien,

I've just created a new branch ansiToHtml with some additions to support colored logs.

However, I am not really keen to merge this feature into master, since it requires to explicitly enable HTML rendering (it could be confusing to have rendered HTML inside logs...)

If you want, I think you can fork the repository, switch to the ansiToHtml branch and
then keep it up-to-date with upstream/master

@zbbfufu
Copy link
Author

zbbfufu commented Mar 14, 2016

Thanks Franceso, I'll try it :)

@francescou
Copy link
Owner

I'm closing the issue, feel free to reopen if necessary

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

No branches or pull requests

2 participants