Security News
Input Validation Vulnerabilities Dominate MITRE's 2024 CWE Top 25 List
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
@kotori-bot/logger
Advanced tools
Here are a simple logger,used mainly in Node.js environment,can record quickly log of application at runtime.
new Logger(options: LoggerOptions)
interface LoggerOptions {
level: LoggerLevel;
filter?: (data: LoggerData) => boolean;;
label: string[];
transports: Transport | Transport[];
}
// ./src/example/example1.ts
import Logger, { ConsoleTransport, LoggerLevel } from '@kotori-bot/logger';
const logger = new Logger({
level: LoggerLevel.TRACE,
label: [],
transports: new ConsoleTransport()
});
logger.info(`base type:`, 'string', 233, null, undefined, true, false, 2.7182818284);
logger.fatal(`normal object (json):`, { value: 1, content: 'content', extends: { value: 2 } }, [
1,
null,
{ value: false },
'string'
]);
const obj: any = {};
obj.value = obj;
logger.error(`loop object:`, obj);
logger.warn(`javascript special type:`, Symbol(233), BigInt('1234567891011121314151617181920'));
logger.debug(`javascript object:`, Math, globalThis);
logger.trace(`javascript constructor:`, Object, Function, String, Number, Boolean, Set, Map, Symbol, Error, Date);
logger.label('label1').info(
`javascript object instance`,
new Map([
[1, 3],
[2, 3],
[3, 4],
[4, 5]
]),
new Set([1, 3, 3, 4, 5, 6, 7, 7, 8]),
new Proxy({}, {}),
new Error('a error'),
new Date()
);
function a() {}
class A {}
const b = () => {};
logger
.label('label father')
.label('label child')
.warn(`function and class`, a, A, b, () => {}, new A());
Reference source of pre-tansports,here are a simple example:
import { LoggerData, Transport } from '@kotori-bot/logger';
interface MyTransportConfig {
/* ... */
}
export class MyTransport extends Transport<MyTransportConfig> {
handle(data: LoggerData) {
/* here are some log handle logic... */
}
escaper = (...args: unknown): string => {
/* if need,you can custom escaper */
/* finally return a string as key msg of LoggerData */
/* it's optional */
};
}
export default MyTransport;
FAQs
Logger For Kotori
The npm package @kotori-bot/logger receives a total of 5 weekly downloads. As such, @kotori-bot/logger popularity was classified as not popular.
We found that @kotori-bot/logger demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.
Research
Security News
A threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.