Initial commit: Extract base Zabbix GraphQl - API functionality from VCR Project and add dynamic schema samples

This commit is contained in:
Andreas Hilbig 2026-01-05 21:05:35 +01:00
commit 92ffe71684
42 changed files with 4234 additions and 0 deletions

64
src/logging/logger.ts Normal file
View file

@ -0,0 +1,64 @@
export enum Loglevel {
ERROR="ERROR", WARN="WARN", INFO="INFO", TRACE="TRACE", DEBUG="DEBUG"
}
export class Logger {
public levels:Set<Loglevel> | undefined = undefined
public logMqtt = true
constructor() {
this.readEnvironmentLogLevel()
}
readEnvironmentLogLevel() {
const levels = process.env.LOG_LEVELS
if (levels) {
const enumLevels = levels.split(",").map(v=> Loglevel[v as keyof typeof Loglevel])
this.levels = new Set<Loglevel>(enumLevels)
}
}
public trace(...data: any[]) {
if (!this.levels || this.levels.has(Loglevel.TRACE)) {
console.log(...data)
if (this.logMqtt) {
// TODO Push to mqtt TEST_STATS_LOG_TOPIC topic
}
}
}
public warn(...data: any[]) {
if (!this.levels || this.levels.has(Loglevel.WARN)) {
console.warn(...data)
if (this.logMqtt) {
// TODO Push to mqtt TEST_STATS_LOG_TOPIC topic
}
}
}
public info(...data: any[]) {
if (!this.levels || this.levels.has(Loglevel.INFO)) {
console.log(...data)
if (this.logMqtt) {
// TODO Push to mqtt TEST_STATS_LOG_TOPIC topic
}
}
}
public error(...data: any[]) {
if (!this.levels || this.levels.has(Loglevel.ERROR)) {
console.error(...data)
if (this.logMqtt) {
// TODO Push to mqtt TEST_STATS_LOG_TOPIC topic
}
}
}
public debug(...data: any[]) {
if (!this.levels || this.levels.has(Loglevel.DEBUG)) {
console.debug(...data)
if (this.logMqtt) {
// TODO Push to mqtt TEST_STATS_LOG_TOPIC topic
}
}
}
}
export const logger = new Logger()