Skip to content

Commit 3e3b36c

Browse files
committed
feat: update log handling and display logic for improved clarity and consistency
Signed-off-by: Manuel Abascal <mjabascal10@gmail.com>
1 parent 4ecaac3 commit 3e3b36c

3 files changed

Lines changed: 24 additions & 12 deletions

File tree

frontend/src/app/app-management/app-logs/app-logs.component.html

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,20 +47,20 @@ <h6 class="card-title mb-0 text-uppercase label-header">
4747
</tr>
4848
</thead>
4949
<tbody *ngIf="logs && !loading">
50-
<tr (click)="message = log.message" *ngFor="let log of logs" class="cursor-pointer">
50+
<tr (click)="message = log.log.msg" *ngFor="let log of logs" class="cursor-pointer">
5151
<td><span>{{log["@timestamp"]| date:'medium':'UTC'}}</span></td>
5252
<td>
53-
<span>{{log.source}}</span>
53+
<span>{{'PANEL ( '+ log.dataSource + ' )'}}</span>
5454
</td>
5555
<td>
56-
<span [ngClass]="getClassByType(log.type)"
56+
<span [ngClass]="getClassByType(log.log.severity)"
5757
class="p-1 border-1 rounded">
58-
{{log.type}}
58+
{{log.log.severity}}
5959
</span>
6060
</td>
6161
<td>
62-
<span [ngClass]="getClassByType(log.type)">
63-
{{getPreview(log.message)}}
62+
<span [ngClass]="getClassByType(log.log.msg)">
63+
{{getPreview(log.log.msg)}}
6464
</span>
6565
</td>
6666
</tr>

frontend/src/app/app-management/app-logs/app-logs.component.ts

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import {AppLogType} from './shared/type/app-log.type';
1515
styleUrls: ['./app-logs.component.css']
1616
})
1717
export class AppLogsComponent implements OnInit {
18-
logs: AppLogType[] = [];
18+
logs: any[] = [];
1919
links: any;
2020
totalItems: number;
2121
page = 1;
@@ -26,8 +26,9 @@ export class AppLogsComponent implements OnInit {
2626
message: string;
2727
req: { filters: ElasticFilterType[], index: string, top: number } = {
2828
filters: [
29-
{field: '@timestamp', operator: ElasticOperatorsEnum.IS_BETWEEN, value: ['now-7d', 'now']}
30-
], index: '.utmstack-logs*', top: 10000000
29+
{field: '@timestamp', operator: ElasticOperatorsEnum.IS_BETWEEN, value: ['now-7d', 'now']},
30+
{field: 'log.containerName.keyword', operator: ElasticOperatorsEnum.IS, value: 'utmstack_backend'}
31+
], index: 'v11-log-utmstack-*', top: 10000000
3132
};
3233
sources = ['PANEL', 'AGENT'];
3334
types = ['ERROR', 'WARNING', 'INFO'];
@@ -100,7 +101,18 @@ export class AppLogsComponent implements OnInit {
100101
}
101102

102103
getPreview(message: string): string {
103-
const preview = message.substring(0, message.indexOf(':')).substring(0, 200);
104-
return preview.length > 200 ? (preview + '..') : preview;
104+
if (!message) { return ''; }
105+
106+
const colonIndex = message.indexOf(':');
107+
const textToTruncate = colonIndex !== -1
108+
? message.substring(0, colonIndex)
109+
: message;
110+
111+
if (textToTruncate.length > 200) {
112+
return textToTruncate.substring(0, 200) + '..';
113+
}
114+
115+
return textToTruncate;
105116
}
117+
106118
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
export enum AppLogTypeEnum {
22
ERROR = 'ERROR',
33
INFO = 'INFO',
4-
WARNING = 'WARNING'
4+
WARNING = 'WARN'
55
}

0 commit comments

Comments
 (0)