Sign-Logger
The best JS/TS logger out there, with everything that you need; ExpressJS, typeorm etc.
Table of contents:
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:
- Adding support for TypeOrm Query logging (see here for more information)
- Adding support for Express logging (see here for more information)
- Adding support for Mongoose logging (see here for more information)
- Deciding if the Transformer should be kept in the library or not
- Clean up & Bug fixes
author not being happy with the looks and mechanics.
If you used sign logger before, you might not recognize the new style of code being used, this revamp was made due to the- Sign logger is now split into two classes - Logger and the Transformer! (See the difference here)
- The logger also comes with internal logs for debugging (optional)
- New fail-safe for possible undefined objects/properties
- No constructor, instead the logger uses methods to customize the logs
Installation
npm install sign-logger
Getting started
Simple error log ES6:
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
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
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
import { Logger } from "sign-logger";
import { createConnection } from "typeorm";
const logger = new Logger();
createConnection({
logger: logger.TypeOrmLogger
// ...
})
That's it!
Mongoose
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
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