merge: resolve conflicts with master
This commit is contained in:
@@ -331,28 +331,12 @@ export class BaileysLogger implements ILogger {
|
|||||||
...(typeof sanitizedObj === 'object' && sanitizedObj !== null ? sanitizedObj : { value: sanitizedObj }),
|
...(typeof sanitizedObj === 'object' && sanitizedObj !== null ? sanitizedObj : { value: sanitizedObj }),
|
||||||
}
|
}
|
||||||
|
|
||||||
// Structured log (using type-safe method call)
|
// Structured log (skip if level is 'silent')
|
||||||
switch (level) {
|
if (level !== 'silent') {
|
||||||
case 'trace':
|
const logMethod = (this.structuredLogger as unknown as Record<string, ((obj: unknown, msg?: string) => void) | undefined>)[level]
|
||||||
this.structuredLogger.trace(enrichedObj, msg)
|
if (logMethod) {
|
||||||
break
|
logMethod.call(this.structuredLogger, enrichedObj, msg)
|
||||||
case 'debug':
|
}
|
||||||
this.structuredLogger.debug(enrichedObj, msg)
|
|
||||||
break
|
|
||||||
case 'info':
|
|
||||||
this.structuredLogger.info(enrichedObj, msg)
|
|
||||||
break
|
|
||||||
case 'warn':
|
|
||||||
this.structuredLogger.warn(enrichedObj, msg)
|
|
||||||
break
|
|
||||||
case 'error':
|
|
||||||
this.structuredLogger.error(enrichedObj, msg)
|
|
||||||
break
|
|
||||||
case 'fatal':
|
|
||||||
this.structuredLogger.fatal(enrichedObj, msg)
|
|
||||||
break
|
|
||||||
default:
|
|
||||||
this.structuredLogger.info(enrichedObj, msg)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Event handler
|
// Event handler
|
||||||
|
|||||||
@@ -505,7 +505,7 @@ const globalCaches: Map<string, Cache<any>> = new Map()
|
|||||||
|
|
||||||
export function getGlobalCache<V>(namespace: string, options?: CacheOptions<V>): Cache<V> {
|
export function getGlobalCache<V>(namespace: string, options?: CacheOptions<V>): Cache<V> {
|
||||||
if (!globalCaches.has(namespace)) {
|
if (!globalCaches.has(namespace)) {
|
||||||
globalCaches.set(namespace, new Cache<V>({ ...options, namespace }))
|
globalCaches.set(namespace, new Cache<V>({ ...options, namespace }) as Cache<V>)
|
||||||
}
|
}
|
||||||
return globalCaches.get(namespace) as Cache<V>
|
return globalCaches.get(namespace) as Cache<V>
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -120,7 +120,7 @@ export class LoggerAdapter implements ILogger {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (this.config.levelMapping && level in this.config.levelMapping) {
|
if (this.config.levelMapping && level in this.config.levelMapping) {
|
||||||
return this.config.levelMapping[level] || 'info'
|
return this.config.levelMapping[level] ?? 'info'
|
||||||
}
|
}
|
||||||
|
|
||||||
return (level as LogLevel) || 'info'
|
return (level as LogLevel) || 'info'
|
||||||
@@ -328,8 +328,8 @@ function createLogMethod(
|
|||||||
if (typeof logger[level] === 'function') {
|
if (typeof logger[level] === 'function') {
|
||||||
;(logger[level] as (obj: unknown, msg?: string) => void)(obj, msg)
|
;(logger[level] as (obj: unknown, msg?: string) => void)(obj, msg)
|
||||||
} else {
|
} else {
|
||||||
// Fallback to console
|
// Fallback to console methods
|
||||||
const consoleMethod = (console as unknown as Record<string, (...args: unknown[]) => void>)[level]
|
const consoleMethod = (console as unknown as Record<string, ((...args: unknown[]) => void) | undefined>)[level]
|
||||||
if (typeof consoleMethod === 'function') {
|
if (typeof consoleMethod === 'function') {
|
||||||
consoleMethod(obj, msg)
|
consoleMethod(obj, msg)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -566,7 +566,7 @@ export class Summary implements BaseMetric {
|
|||||||
* Metrics registry
|
* Metrics registry
|
||||||
*/
|
*/
|
||||||
export class MetricsRegistry {
|
export class MetricsRegistry {
|
||||||
private metrics: Map<string, Counter | Gauge | Histogram | Summary> = new Map()
|
private metricsMap: Map<string, Counter | Gauge | Histogram | Summary> = new Map()
|
||||||
private prefix: string
|
private prefix: string
|
||||||
private defaultLabels: Labels
|
private defaultLabels: Labels
|
||||||
|
|
||||||
@@ -580,7 +580,7 @@ export class MetricsRegistry {
|
|||||||
*/
|
*/
|
||||||
register<T extends Counter | Gauge | Histogram | Summary>(metric: T): T {
|
register<T extends Counter | Gauge | Histogram | Summary>(metric: T): T {
|
||||||
const fullName = this.prefix ? `${this.prefix}_${metric.name}` : metric.name
|
const fullName = this.prefix ? `${this.prefix}_${metric.name}` : metric.name
|
||||||
this.metrics.set(fullName, metric)
|
this.metricsMap.set(fullName, metric)
|
||||||
return metric
|
return metric
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -589,7 +589,7 @@ export class MetricsRegistry {
|
|||||||
*/
|
*/
|
||||||
get(name: string): Counter | Gauge | Histogram | Summary | undefined {
|
get(name: string): Counter | Gauge | Histogram | Summary | undefined {
|
||||||
const fullName = this.prefix ? `${this.prefix}_${name}` : name
|
const fullName = this.prefix ? `${this.prefix}_${name}` : name
|
||||||
return this.metrics.get(fullName)
|
return this.metricsMap.get(fullName)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -597,14 +597,14 @@ export class MetricsRegistry {
|
|||||||
*/
|
*/
|
||||||
remove(name: string): boolean {
|
remove(name: string): boolean {
|
||||||
const fullName = this.prefix ? `${this.prefix}_${name}` : name
|
const fullName = this.prefix ? `${this.prefix}_${name}` : name
|
||||||
return this.metrics.delete(fullName)
|
return this.metricsMap.delete(fullName)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reset all metrics
|
* Reset all metrics
|
||||||
*/
|
*/
|
||||||
resetAll(): void {
|
resetAll(): void {
|
||||||
for (const metric of this.metrics.values()) {
|
for (const metric of this.metricsMap.values()) {
|
||||||
metric.reset()
|
metric.reset()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -615,7 +615,7 @@ export class MetricsRegistry {
|
|||||||
async getMetricsOutput(): Promise<string> {
|
async getMetricsOutput(): Promise<string> {
|
||||||
const lines: string[] = []
|
const lines: string[] = []
|
||||||
|
|
||||||
for (const [name, metric] of this.metrics.entries()) {
|
for (const [name, metric] of this.metricsMap) {
|
||||||
lines.push(`# HELP ${name} ${metric.help}`)
|
lines.push(`# HELP ${name} ${metric.help}`)
|
||||||
lines.push(`# TYPE ${name} ${metric.type}`)
|
lines.push(`# TYPE ${name} ${metric.type}`)
|
||||||
|
|
||||||
|
|||||||
@@ -559,7 +559,9 @@ export function extractTraceHeaders(headers: Record<string, string | undefined>)
|
|||||||
options.baggage = {}
|
options.baggage = {}
|
||||||
const pairs = baggageHeader.split(',')
|
const pairs = baggageHeader.split(',')
|
||||||
for (const pair of pairs) {
|
for (const pair of pairs) {
|
||||||
const [key, value] = pair.split('=')
|
const parts = pair.split('=')
|
||||||
|
const key = parts[0]
|
||||||
|
const value = parts[1]
|
||||||
if (key && value) {
|
if (key && value) {
|
||||||
options.baggage[key.trim()] = decodeURIComponent(value.trim())
|
options.baggage[key.trim()] = decodeURIComponent(value.trim())
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user