Compare commits
2 Commits
2.3.3
..
f9cb676b46
| Author | SHA1 | Date | |
|---|---|---|---|
| f9cb676b46 | |||
| 4dcc4fad25 |
@@ -5,7 +5,7 @@ export class ApiLogAppender implements LogAppender {
|
|||||||
public batchSize = 10
|
public batchSize = 10
|
||||||
public minimumTimePassedInSec = 60
|
public minimumTimePassedInSec = 60
|
||||||
public maximumTimePassedInSec = 120
|
public maximumTimePassedInSec = 120
|
||||||
public threshold = LogLevel.ALL
|
public threshold: LogLevel
|
||||||
|
|
||||||
private msgBuffer: FlattenedLogMessage[] = []
|
private msgBuffer: FlattenedLogMessage[] = []
|
||||||
private lastSent = 0
|
private lastSent = 0
|
||||||
@@ -16,9 +16,7 @@ export class ApiLogAppender implements LogAppender {
|
|||||||
threshold?: LogLevel
|
threshold?: LogLevel
|
||||||
) {
|
) {
|
||||||
setTimeout(this.checkPost, 1000)
|
setTimeout(this.checkPost, 1000)
|
||||||
if (threshold) {
|
this.threshold = threshold ?? LogLevel.ALL
|
||||||
this.threshold = threshold
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public appendMessage(msg: LogMessage): void {
|
public appendMessage(msg: LogMessage): void {
|
||||||
|
|||||||
@@ -0,0 +1,21 @@
|
|||||||
|
import type { LogAppender } from './log-appender'
|
||||||
|
import { LogLevel, type LogMessage } from './log-message'
|
||||||
|
|
||||||
|
export class BufferLogAppender implements LogAppender {
|
||||||
|
public threshold: LogLevel
|
||||||
|
public buffer: LogMessage[]
|
||||||
|
|
||||||
|
constructor(buffer?: LogMessage[], threshold?: LogLevel) {
|
||||||
|
this.buffer = buffer ?? []
|
||||||
|
this.threshold = threshold ?? LogLevel.ALL
|
||||||
|
}
|
||||||
|
|
||||||
|
public appendMessage(msg: LogMessage): void {
|
||||||
|
if (this.threshold && msg.level < this.threshold) return
|
||||||
|
else this.buffer.push(msg)
|
||||||
|
}
|
||||||
|
|
||||||
|
public clearBuffer(): void {
|
||||||
|
this.buffer.length = 0
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -18,16 +18,12 @@ import { LogAppender } from './log-appender'
|
|||||||
* data for inspection in the browser's developer tools.
|
* data for inspection in the browser's developer tools.
|
||||||
*/
|
*/
|
||||||
export class ConsoleLogAppender implements LogAppender {
|
export class ConsoleLogAppender implements LogAppender {
|
||||||
public threshold = LogLevel.ALL
|
public threshold: LogLevel
|
||||||
public formatter: LogMessageFormatter = flattenMessage
|
public formatter: LogMessageFormatter
|
||||||
|
|
||||||
constructor(threshold?: LogLevel, formatter?: LogMessageFormatter) {
|
constructor(threshold?: LogLevel, formatter?: LogMessageFormatter) {
|
||||||
if (threshold) {
|
this.threshold = threshold ?? LogLevel.ALL
|
||||||
this.threshold = threshold
|
this.formatter = formatter ?? flattenMessage
|
||||||
}
|
|
||||||
if (formatter) {
|
|
||||||
this.formatter = formatter
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public appendMessage(msg: LogMessage): void {
|
public appendMessage(msg: LogMessage): void {
|
||||||
|
|||||||
Reference in New Issue
Block a user