UNPKG

sign-logger

Version:

A simple but nice looking logger for 16 bit color consoles!

125 lines (82 loc) 3.32 kB
# Sign-Logger The best JS/TS logger out there, with everything that you need; ExpressJS, typeorm etc. ## Table of contents: - [What's new](#what's-new) - [Installation](#installation) - [Getting started](#getting-started) - [Changelog](#changelog) ## What's new ###### TypeOrm, ExpressJS and Mongoose support is here! After almost 10 months without updates, sign-logger is finally getting an update! This update will be primarily focused at: 1. Adding support for TypeOrm Query logging (see [here](#typeorm) for more information) 2. Adding support for Express logging (see [here](#express) for more information) 2. Adding support for Mongoose logging (see [here](#mongoose) for more information) 3. Deciding if the Transformer should be kept in the library or not 4. Clean up & Bug fixes ###### If you used sign logger before, you might not recognize the new style of code being used, this revamp was made due to the [author](#authors) not being happy with the looks and mechanics. 1. Sign logger is now split into two classes - Logger and the Transformer! (See the difference [here](#difference)) 2. The logger also comes with internal logs for debugging (optional) 3. New fail-safe for possible undefined objects/properties 4. No constructor, instead the logger uses methods to customize the logs ## Installation ``` npm install sign-logger ``` ## Getting started #### Simple error log ES6: ```ts import { Logger } from "sign-logger"; const logger = new Logger(); logger.error("BEEP BOOP! ERROR!"); // [2020-11-27 16:55] <Error> BEEP BOOP! ERROR! ``` #### Transform usage ```ts import { Transformer } from "sign-logger"; const transformer = new Transformer(); console.log(transformer.error("This RETURNS the value, it does not log it!")); // [2020-11-27 16:55] <Error> This RETURNS the value, it does not log it! ``` #### Express ```ts import { Logger } from "sign-logger"; import express from "express"; const app = express(); const logger = new Logger(); app.use(logger.ExpressJS()); app.get("/", (req, res) => { res.send("Hello world!"); }) app.listen(8080, () => logger.info("Server listening on 8080!")); ``` Now go to localhost:8080 and bam! The request has been logged #### TypeOrm ````ts import { Logger } from "sign-logger"; import { createConnection } from "typeorm"; const logger = new Logger(); createConnection({ logger: logger.TypeOrmLogger // ... }) ```` That's it! #### Mongoose ```ts import { Logger } from "sign-Logger"; import mongoose from "mongoose"; const logger = new Logger(); mongoose.set("debug", logger.Mongoose()) // ... ``` That's all you need! **Note:** This has not been fully tested yet, so expect bugs and please report them [here](https://github.com/blaziftOrg/sign-logger/issues/new) ## Changelog >* 2.3.5 Added support for mongoose logging, have any suggestions on other libs we can support? Tell us in an issue! >* 2.3.4 Changed the way you call `<Logger>.ExpressJS` and changed the license. TODO: Add different modes of logging >* 2.3.3 Removed an internal debugging log >* 2.3.2 Bug fixes for ExpressJS involving problems with `this` ## Authors #### [Collbrothers](https://github.com/Collbrothers)