Compare commits

..

3 Commits

Author SHA1 Message Date
d565372adb
More typings 2023-04-13 19:38:48 +03:00
e19299dd62
v2.2.0 2023-04-13 19:38:31 +03:00
e6a20564b8
v2.1.4 2023-04-13 19:19:07 +03:00
5 changed files with 57 additions and 4 deletions

View File

@ -1,6 +1,6 @@
{
"name": "@navy.gif/logger",
"version": "2.1.3",
"version": "2.2.0",
"description": "Logging thing",
"author": "Navy.gif",
"license": "MIT",

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) => {