Skip to content

Commit

Permalink
fixed presenting timestamps in step logs
Browse files Browse the repository at this point in the history
  • Loading branch information
godfryd committed Nov 26, 2023
1 parent 9425950 commit 97adb3e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 15 deletions.
2 changes: 1 addition & 1 deletion ui/src/app/logs-panel/logs-panel.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@
class="flex">
<div style="width: 3rem; color: #888; text-align: right; margin-right: 0.5rem; flex: none;">{{ stepsStates[idx].start + l_idx }}</div>
<div style="white-space: pre-wrap; overflow-x: auto; word-break: break-word; margin: 0;"
[innerHTML]="prepareLogLine(stepsStates[idx], l.message, l.level) | noSanitize">
[innerHTML]="prepareLogLine(stepsStates[idx], l) | noSanitize">
</div>
</div>
</div>
Expand Down
23 changes: 9 additions & 14 deletions ui/src/app/logs-panel/logs-panel.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,9 @@ import { DomSanitizer, SafeHtml } from '@angular/platform-browser'
import { Subscription } from 'rxjs'

import { parse } from 'ansicolor'
import { DateTime } from 'luxon'

import { ExecutionService } from '../backend/api/execution.service'
import { replaceEntityIntoLink } from '../utils'
import { replaceEntityIntoLink, datetimeToLocal } from '../utils'

@Component({
selector: 'app-logs-panel',
Expand Down Expand Up @@ -402,20 +401,16 @@ export class LogsPanelComponent implements OnInit, OnDestroy {
return kv
}

prepareLogLine(stepState, line, level) {
const currTs = line.slice(0, 23)
const currTsObj = DateTime.fromFormat(currTs, 'yyyy-MM-dd HH:mm:ss,SSS')
prepareLogLine(stepState, logEntry) {
let line = logEntry.message
const level = logEntry.level
if (this.logTimestamps) {
// fix missing timestamps
if (currTsObj.isValid) {
stepState.prevTs = currTs
} else if (stepState.prevTs) {
line = stepState.prevTs + ' ' + line
const currTs = logEntry.time
if (currTs) {
stepState.prevTs = datetimeToLocal(currTs, 'yy-LL-dd HH:mm:ss')
}
} else {
// strip timestamps
if (currTsObj.isValid) {
line = line.slice(24)
if (stepState.prevTs) {
line = stepState.prevTs + ' ' + line
}
}

Expand Down

0 comments on commit 97adb3e

Please sign in to comment.