mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-03-31 20:43:41 +00:00
feat: refactor logs (#2555)
* feat: refactor logs * chore: comments * feat: add system logs * feat: update shared logs
This commit is contained in:
20
web/projects/shared/src/util/convert-ansi.ts
Normal file
20
web/projects/shared/src/util/convert-ansi.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
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 />')
|
||||
}
|
||||
Reference in New Issue
Block a user