More typings

This commit is contained in:
Erik 2023-04-13 19:38:48 +03:00
parent e19299dd62
commit d565372adb
Signed by: Navy.gif
GPG Key ID: 2532FBBB61C65A68
4 changed files with 56 additions and 3 deletions

View File

@ -3,6 +3,7 @@
import Defaults from "./Defaults.js";
import { inspect } from "node:util";
import { WriteOptions } from "./Types.js";
import { Logger } from "./LoggerInterface.js";
type ClientOptions = {
name?: string,
@ -18,7 +19,7 @@ type TransportOptions = {
type: string
}
class LoggerClient {
class LoggerClient implements Logger {
static MaxChars = 0;
@ -88,6 +89,28 @@ class LoggerClient {
}
// These methods are dynamically implemented by the constructor
// eslint-disable-next-line @typescript-eslint/no-unused-vars
error (_str: string): void {
throw new Error('Method not implemented.');
}
// eslint-disable-next-line @typescript-eslint/no-unused-vars
warn (_str: string): void {
throw new Error('Method not implemented.');
}
// eslint-disable-next-line @typescript-eslint/no-unused-vars
status (_str: string): void {
throw new Error('Method not implemented.');
}
// eslint-disable-next-line @typescript-eslint/no-unused-vars
info (_str: string): void {
throw new Error('Method not implemented.');
}
// eslint-disable-next-line @typescript-eslint/no-unused-vars
debug (_str: string): void {
throw new Error('Method not implemented.');
}
}
export default LoggerClient;

7
src/LoggerInterface.ts Normal file
View File

@ -0,0 +1,7 @@
export interface Logger {
error(str: string): void
warn(str: string): void
status(str: string): void
info(str: string): void
debug(str: string): void
}

View File

@ -12,6 +12,7 @@ import DiscordWebhook from '@navy.gif/discord-webhook';
import Defaults, { LogLevel } from './Defaults.js';
import { Shard, WriteOptions } from './Types.js';
import { addLogLevel } from '../index.js';
import { Logger } from './LoggerInterface.js';
const DAY = 1000 * 60 * 60 * 24;
@ -32,7 +33,7 @@ type WriteStreams = {
[key:string]: fs.WriteStream
}
class MasterLogger {
class MasterLogger implements Logger {
#_guard: string;
#_logLevel: LogLevel;
@ -225,6 +226,28 @@ class MasterLogger {
return moment().format('YYYY-MM-DD HH:mm:ss');
}
// These methods are dynamically implemented by the constructor
// eslint-disable-next-line @typescript-eslint/no-unused-vars
error (_str: string): void {
throw new Error('Method not implemented.');
}
// eslint-disable-next-line @typescript-eslint/no-unused-vars
warn (_str: string): void {
throw new Error('Method not implemented.');
}
// eslint-disable-next-line @typescript-eslint/no-unused-vars
status (_str: string): void {
throw new Error('Method not implemented.');
}
// eslint-disable-next-line @typescript-eslint/no-unused-vars
info (_str: string): void {
throw new Error('Method not implemented.');
}
// eslint-disable-next-line @typescript-eslint/no-unused-vars
debug (_str: string): void {
throw new Error('Method not implemented.');
}
}
export default MasterLogger;

View File

@ -25,7 +25,7 @@ const logger = new MasterLogger({
console.log(logger);
logger.setLogLevel(LogLevel.access);
console.log(logger.logLevel);
process.exit();
// process.exit();
logger.info('Test');
const spawn = (child) => {