Milestone v1 (v2.0.0): Mokosh — Session Capture #1
@@ -1,4 +1,11 @@
|
|||||||
// Логгер для Service Worker
|
// Логгер для Service Worker
|
||||||
|
// IN-02 fix: migrated from `...args: any[]` to `...args: unknown[]` so
|
||||||
|
// the type signature matches OffscreenLogger and aligns with strict-
|
||||||
|
// mode hygiene. console.log accepts unknown[] natively (its variadic
|
||||||
|
// signature is `(...data: any[]) => void`, so passing unknown values
|
||||||
|
// works fine — the underlying console.* coerces with String() / object
|
||||||
|
// inspection). Call sites at content/popup/background passed already-
|
||||||
|
// typed values, so no widening was required.
|
||||||
export class Logger {
|
export class Logger {
|
||||||
private context: string;
|
private context: string;
|
||||||
|
|
||||||
@@ -6,25 +13,25 @@ export class Logger {
|
|||||||
this.context = context;
|
this.context = context;
|
||||||
}
|
}
|
||||||
|
|
||||||
private logWithLevel(level: 'log' | 'warn' | 'error', ...args: any[]) {
|
private logWithLevel(level: 'log' | 'warn' | 'error', ...args: unknown[]) {
|
||||||
const timestamp = new Date().toISOString();
|
const timestamp = new Date().toISOString();
|
||||||
console[level](`[SW:${this.context}] ${timestamp}`, ...args);
|
console[level](`[SW:${this.context}] ${timestamp}`, ...args);
|
||||||
}
|
}
|
||||||
|
|
||||||
log(...args: any[]) {
|
log(...args: unknown[]) {
|
||||||
this.logWithLevel('log', ...args);
|
this.logWithLevel('log', ...args);
|
||||||
}
|
}
|
||||||
|
|
||||||
warn(...args: any[]) {
|
warn(...args: unknown[]) {
|
||||||
this.logWithLevel('warn', ...args);
|
this.logWithLevel('warn', ...args);
|
||||||
}
|
}
|
||||||
|
|
||||||
error(...args: any[]) {
|
error(...args: unknown[]) {
|
||||||
this.logWithLevel('error', ...args);
|
this.logWithLevel('error', ...args);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Логгер для Content Script
|
// Логгер для Content Script (IN-02 fix: see Logger above)
|
||||||
export class ContentLogger {
|
export class ContentLogger {
|
||||||
private context: string;
|
private context: string;
|
||||||
|
|
||||||
@@ -32,27 +39,27 @@ export class ContentLogger {
|
|||||||
this.context = context;
|
this.context = context;
|
||||||
}
|
}
|
||||||
|
|
||||||
private logWithLevel(level: 'log' | 'warn' | 'error', ...args: any[]) {
|
private logWithLevel(level: 'log' | 'warn' | 'error', ...args: unknown[]) {
|
||||||
const timestamp = new Date().toISOString();
|
const timestamp = new Date().toISOString();
|
||||||
console[level](`[CS:${this.context}] ${timestamp}`, ...args);
|
console[level](`[CS:${this.context}] ${timestamp}`, ...args);
|
||||||
}
|
}
|
||||||
|
|
||||||
log(...args: any[]) {
|
log(...args: unknown[]) {
|
||||||
this.logWithLevel('log', ...args);
|
this.logWithLevel('log', ...args);
|
||||||
}
|
}
|
||||||
|
|
||||||
warn(...args: any[]) {
|
warn(...args: unknown[]) {
|
||||||
this.logWithLevel('warn', ...args);
|
this.logWithLevel('warn', ...args);
|
||||||
}
|
}
|
||||||
|
|
||||||
error(...args: any[]) {
|
error(...args: unknown[]) {
|
||||||
this.logWithLevel('error', ...args);
|
this.logWithLevel('error', ...args);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Логгер для Offscreen Document
|
// Логгер для Offscreen Document
|
||||||
// Note: uses `...args: unknown[]` (strict-mode hygiene) vs Logger / ContentLogger
|
// All three loggers now share the same `...args: unknown[]` signature
|
||||||
// which retain the legacy `...args: any[]` — see plan 01-03 style_divergence_note.
|
// (IN-02 fix retired the style divergence noted in plan 01-03).
|
||||||
export class OffscreenLogger {
|
export class OffscreenLogger {
|
||||||
private context: string;
|
private context: string;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user