log-smth

This is a custom logging library I'm currently, working on, feel free to use it.

Usage no npm install needed!

<script type="module">
  import logSmth from 'https://cdn.skypack.dev/log-smth';
</script>

README

log-smth

This is a custom logging library I'm currently, working on, feel free to use it.

import { Logger } from './index';

const logger: Logger = new Logger({
    timestamps: true, // If logs should show the timestamp too.
    defaultLog: 'log', // The default log type to use.
    logFileOptions: {
        logFile: true, // Whether you should use a log file or not.
        logDirPath: process.cwd(), // Where the log file should be stored.
        logLevels: ['error', 'warn'], // Which log levels should be logged.
        fileType: 'txt', // Which filetype should be used for the log file.
        logStack: true, // Whether stack traces should be logged or not.
        pipeText: true, // Whether streams should be used or not. ( Not compatible with JSON )
    },
    callback: (options: { message: string; logLevel: string }) => { // Yeah, a callback function. Awesome, right? 
        console.log(options.message); // This function'll run everytime
    },
});

logger.log({ 'message': 'Hello.', 'logLevel': 'info' });
logger.log({ 'message': 'Hello.', 'logLevel': 'warn' });
logger.log({ 'message': 'Hello.', 'logLevel': 'error' });
logger.log({ 'message': 'Hello.', 'logLevel': 'success' });