mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-03-26 10:21:52 +00:00
* feat: refactor logs * chore: comments * feat: add system logs * feat: update shared logs
21 lines
522 B
TypeScript
21 lines
522 B
TypeScript
import { Log } from '../types/api'
|
|
import { toLocalIsoString } from './to-local-iso-string'
|
|
|
|
const Convert = require('ansi-to-html')
|
|
const CONVERT = new Convert({
|
|
bg: 'transparent',
|
|
colors: { 4: 'Cyan' },
|
|
escapeXML: true,
|
|
})
|
|
|
|
export function convertAnsi(entries: readonly Log[]): string {
|
|
return entries
|
|
.map(
|
|
({ timestamp, message }) =>
|
|
`<b style="color: #FFF">${toLocalIsoString(
|
|
new Date(timestamp),
|
|
)}</b> ${CONVERT.toHtml(message)}`,
|
|
)
|
|
.join('<br />')
|
|
}
|