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

Add color rendering for log output #131

Open
LordMike opened this issue Oct 21, 2018 · 4 comments
Open

Add color rendering for log output #131

LordMike opened this issue Oct 21, 2018 · 4 comments
Assignees

Comments

@LordMike
Copy link

When a job has run, the shell module in particular may output colorized text, using f.ex. using ANSI escape codes.

image

Colorizing this in the Web UI would be awesome :)

@jhuckaby
Copy link
Owner

Will add to TODO list. Thanks!

@jhuckaby jhuckaby self-assigned this Oct 26, 2018
@mikeTWC1984
Copy link

+1

@mikeTWC1984
Copy link

I figured out how to achieve this by creating custom plugin (using html block). I think for the Event Log itself and error labels it's actually better to trim ansi sequences. Below is the sample I did with powershell. It needs ansi-to-html though (npm install ansi-to-html -g)

#!/usr/bin/pwsh
$params = $Input | Convertfrom-Json

$psfile = $params.params.psfile

$output = pwsh -f $psfile *>&1

if($?) {
    $exit =  @{complete=1} | convertto-json -compress;
}
else
{  $e = $error[1][0].Exception.Message | sed 's/\x1b\[[0-9;]*m//g'
   if($e) {$e = $e.Trim().TrimStart("|") }
   if($e.Length -gt 185) {$e = $e.Substring(1,185) + " ..." }
   $exit = @{complete=1; code = "RuntimeException" ; description = "$e" } | convertto-json -compress;
}

$title = "Console output"

$divStyle = '"background-color:black;color:#f2f2f2;background-image: radial-gradient(rgba(47, 79, 79, 0.75), black 120%);font: 1rem Inconsolata, monospace;"'

$content =  $output | ansi-to-html  | Out-String

$report = @{

    html = @{
       title = $title
       content = "<div style=$divStyle><pre>$content</pre></div>"
       #caption =  $caption
    }

}

$report | ConvertTo-Json -Compress

Write-Host $exit

@mikeTWC1984
Copy link

btw, if plugin is CRLF file it will crash cronicle. make sure you use LF.

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

3 participants