Compare commits
No commits in common. "e9aa4ed2c0f75ac10e91d26c29a84b00e39f74f0" and "eb136291c20a50b3c60d8138348bd7d02679313c" have entirely different histories.
e9aa4ed2c0
...
eb136291c2
8
index.ts
8
index.ts
@ -2,8 +2,7 @@ import MasterLogger from './src/MasterLogger.js';
|
||||
import LoggerClient from './src/LoggerClient.js';
|
||||
import Defaults, { LogLevel } from './src/Defaults.js';
|
||||
|
||||
export { WebhookClientOptions } from '@navy.gif/discord-webhook';
|
||||
export { WriteOptions, LogFunction, Loggable } from './src/Types.js';
|
||||
export { WriteOptions, LogFunction } from './src/Types.js';
|
||||
export { LoggerClientOptions, LoggerMasterOptions } from './src/Defaults.js';
|
||||
|
||||
const addLogLevel = (name: string, level: number) =>
|
||||
@ -17,10 +16,9 @@ const addLogLevel = (name: string, level: number) =>
|
||||
LogLevel[LogLevel[name] = level] = name;
|
||||
};
|
||||
|
||||
|
||||
export {
|
||||
MasterLogger,
|
||||
LoggerClient,
|
||||
Defaults,
|
||||
LogLevel,
|
||||
addLogLevel,
|
||||
Defaults, LogLevel, addLogLevel,
|
||||
};
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@navy.gif/logger",
|
||||
"version": "2.5.3",
|
||||
"version": "2.5.0",
|
||||
"description": "Logging thing",
|
||||
"author": "Navy.gif",
|
||||
"license": "MIT",
|
||||
@ -29,7 +29,7 @@
|
||||
"typescript": "^5.0.4"
|
||||
},
|
||||
"dependencies": {
|
||||
"@navy.gif/discord-webhook": "^1.2.2",
|
||||
"@navy.gif/discord-webhook": "^1.0.0",
|
||||
"chalk": "^4.1.2",
|
||||
"moment": "^2.29.4"
|
||||
},
|
||||
|
@ -9,10 +9,8 @@ type TransportOptions = {
|
||||
} & WriteOptions
|
||||
|
||||
const validKeys = [ 'labels' ];
|
||||
const isTransportOpts = (obj: unknown): obj is TransportOptions =>
|
||||
const isTransportOpts = (obj: object): obj is TransportOptions =>
|
||||
{
|
||||
if (!obj || typeof obj !== 'object')
|
||||
return false;
|
||||
const isWriteOption = isWriteOptions(obj);
|
||||
const keys = Object.keys(obj);
|
||||
return isWriteOption || keys.some(key => validKeys.includes(key));
|
||||
@ -20,7 +18,9 @@ const isTransportOpts = (obj: unknown): obj is TransportOptions =>
|
||||
|
||||
class LoggerClient implements Logger
|
||||
{
|
||||
|
||||
static MaxChars = 0;
|
||||
|
||||
[key: string]: LogFunction | unknown;
|
||||
|
||||
#_guard: string;
|
||||
|
@ -208,7 +208,7 @@ class MasterLogger implements Logger
|
||||
});
|
||||
}
|
||||
|
||||
write (type = 'info', ...args: [...entries: Loggable[], options: WriteOptions | Loggable])
|
||||
write (type = 'info', ...args: [...entries: Loggable[], options: WriteOptions])
|
||||
{
|
||||
const last = args[args.length - 1];
|
||||
let { subheader = '', shard, broadcast = false, labels = [] }: WriteOptions = {};
|
||||
|
@ -10,10 +10,8 @@ export const makePlainError = (err: Error) =>
|
||||
};
|
||||
|
||||
const validKeys = [ 'subheader', 'shard', 'broadcast', 'labels' ];
|
||||
export const isWriteOptions = (obj: unknown, extended = false): obj is WriteOptions =>
|
||||
export const isWriteOptions = (obj: object, extended = false): obj is WriteOptions =>
|
||||
{
|
||||
if (!obj || typeof obj !== 'object')
|
||||
return false;
|
||||
const keys = Object.keys(obj);
|
||||
// Check for invalid keys, in some cases an arbitrary object might share keys
|
||||
// while still allowing for an option to be extended
|
||||
|
@ -48,10 +48,10 @@
|
||||
resolved "https://registry.corgi.wtf/@humanwhocodes%2fobject-schema/-/object-schema-1.2.1.tgz#b520529ec21d8e5945a1851dfd1c32e94e39ff45"
|
||||
integrity sha512-ZnQMnLV4e7hDlUvw8H+U8ASL02SS2Gn6+9Ac3wGGLIe7+je2AeAOxPY+izIPJDfFDb7eDjev0Us8MO1iFRN8hA==
|
||||
|
||||
"@navy.gif/discord-webhook@^1.2.2":
|
||||
version "1.2.2"
|
||||
resolved "https://registry.corgi.wtf/@navy.gif/discord-webhook/-/discord-webhook-1.2.2.tgz#942f4f67aacaebbe6493bee4094acdaef6cff0e2"
|
||||
integrity sha512-lcO/o+iAeFUoLKl9u+a9cZSEnxmuczmI7qQqT1MWnSMDR5jQaiUu2sJRTvDTINfiGgu5kxqRd1NvmHMpkKabfg==
|
||||
"@navy.gif/discord-webhook@^1.0.0":
|
||||
version "1.2.0"
|
||||
resolved "https://registry.corgi.wtf/@navy.gif/discord-webhook/-/discord-webhook-1.2.0.tgz#cb2780c7d3f09c6b49958459d9f01e45f3f187af"
|
||||
integrity sha512-fGwzHkOB9XMc+dCHZGyMUtc/SzNnowC/MGt0Tr6Vwx5EVyO7TQe+1lB44yrOMsjdNpJg6Kp0x5tgQOLHqKlJzA==
|
||||
dependencies:
|
||||
node-fetch "2"
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user