Improve metric logging
This commit is contained in:
@@ -43,17 +43,15 @@ export class MetricsClient<M extends Record<string, any>> {
|
|||||||
) {
|
) {
|
||||||
this.start()
|
this.start()
|
||||||
|
|
||||||
this.queue.push({
|
const e = {
|
||||||
time: Date.now(),
|
time: Date.now(),
|
||||||
event,
|
event,
|
||||||
payload,
|
payload,
|
||||||
metadata,
|
metadata,
|
||||||
})
|
}
|
||||||
|
this.queue.push(e)
|
||||||
|
|
||||||
logger.info(`event: ${event as string}`, {
|
logger.info(`event: ${e.event as string}`, e)
|
||||||
payload,
|
|
||||||
__metadata__: metadata, // special logger field
|
|
||||||
})
|
|
||||||
|
|
||||||
if (this.queue.length > this.maxBatchSize) {
|
if (this.queue.length > this.maxBatchSize) {
|
||||||
this.flush()
|
this.flush()
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ export const consoleTransport: Transport = (
|
|||||||
if (IS_WEB) {
|
if (IS_WEB) {
|
||||||
if (hasMetadata) {
|
if (hasMetadata) {
|
||||||
console.groupCollapsed(msg)
|
console.groupCollapsed(msg)
|
||||||
console.log(metadata)
|
console.log(prepareMetadata(metadata))
|
||||||
console.groupEnd()
|
console.groupEnd()
|
||||||
} else {
|
} else {
|
||||||
console.log(msg)
|
console.log(msg)
|
||||||
|
|||||||
Reference in New Issue
Block a user