paperless-ngx/src-ui/src/app/components/manage/logs/logs.component.ts

52 lines
1.1 KiB
TypeScript
Raw Normal View History

2021-02-06 17:07:25 +01:00
import { Component, ElementRef, OnInit, ViewChild } from '@angular/core';
import { LogService } from 'src/app/services/rest/log.service';
2020-10-27 01:10:18 +01:00
@Component({
selector: 'app-logs',
templateUrl: './logs.component.html',
styleUrls: ['./logs.component.scss']
2020-10-27 01:10:18 +01:00
})
export class LogsComponent implements OnInit {
2020-12-14 20:59:18 +01:00
constructor(private logService: LogService) { }
2021-02-06 17:07:25 +01:00
logs: string[] = []
2020-11-02 15:56:14 +01:00
2021-02-06 17:07:25 +01:00
logFiles: string[] = []
2021-02-06 17:07:25 +01:00
activeLog: string
2021-02-06 17:07:25 +01:00
ngOnInit(): void {
this.logService.list().subscribe(result => {
this.logFiles = result
if (this.logFiles.length > 0) {
this.activeLog = this.logFiles[0]
this.reloadLogs()
}
})
2020-10-27 01:10:18 +01:00
}
2021-02-06 17:07:25 +01:00
reloadLogs() {
this.logService.get(this.activeLog).subscribe(result => {
this.logs = result
2021-02-06 18:51:31 +01:00
}, error => {
this.logs = []
2021-02-06 17:07:25 +01:00
})
2020-11-02 15:56:14 +01:00
}
2021-02-06 17:07:25 +01:00
getLogLevel(log: string) {
if (log.indexOf("[DEBUG]") != -1) {
return 10
} else if (log.indexOf("[WARNING]") != -1) {
return 30
} else if (log.indexOf("[ERROR]") != -1) {
return 40
} else if (log.indexOf("[CRITICAL]") != -1) {
return 50
} else {
return 20
}
2020-11-02 15:56:14 +01:00
}
2020-10-27 01:10:18 +01:00
}