1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00

remove sentry logger-transport (#6345)

Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com>

Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com>
This commit is contained in:
Jari Kolehmainen 2022-10-06 17:22:03 +03:00 committed by GitHub
parent 8c49ea8148
commit 351ad503c8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 0 additions and 66 deletions

View File

@ -1,6 +0,0 @@
/**
* Copyright (c) OpenLens Authors. All rights reserved.
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
export * from "./sentry";

View File

@ -1,60 +0,0 @@
/**
* Copyright (c) OpenLens Authors. All rights reserved.
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
import Transport from "winston-transport";
import { LEVEL } from "triple-beam";
import { Severity } from "@sentry/browser";
import * as Sentry from "@sentry/electron";
const SENTRY_LEVELS_MAP = {
silly: Severity.Debug,
verbose: Severity.Debug,
debug: Severity.Debug,
info: Severity.Info,
warn: Severity.Warning,
error: Severity.Error,
};
const WINSTON_CMP: Record<WinstonLevel, Set<WinstonLevel>> = {
silly: new Set(["silly", "verbose", "debug", "info", "warn", "error"]),
verbose: new Set(["verbose", "debug", "info", "warn", "error"]),
debug: new Set(["debug", "info", "warn", "error"]),
info: new Set(["info", "warn", "error"]),
warn: new Set(["warn", "error"]),
error: new Set(["error"]),
};
export type WinstonLevel = keyof typeof SENTRY_LEVELS_MAP;
export class SentryTransport extends Transport {
logLevels: Set<WinstonLevel>;
constructor(minWinstonLevel: WinstonLevel) {
super();
this.logLevels = WINSTON_CMP[minWinstonLevel];
}
log(info: any, next: () => void) {
setImmediate(() => {
this.emit("logged", info);
});
const { message, level: _, tags, user, ...extra } = info;
const winstonLevel: WinstonLevel = info[LEVEL];
const level = SENTRY_LEVELS_MAP[winstonLevel];
try {
if (this.logLevels.has(winstonLevel)) {
Sentry.captureMessage(message, {
level,
tags,
extra,
});
}
} finally {
next();
}
}
}