mathew-kurian / Scribe.js

:scroll: Node.js logging made simple! Online access to logs and more...
https://mathew-kurian.github.io/Scribe.js/
MIT License
284 stars 45 forks source link

Scribe.js 2.0.0 beta #15

Closed guillaumewuip closed 9 years ago

guillaumewuip commented 9 years ago

Hi @bluejamesbond !

As promised, I've worked quite a lot on Scribe.js on my free time since I've discovered the project.

Here's is a PR sharing with you my work. I think of it as the V2 of ScribeJS since a lot of things have changed and all the code has been refactored. My moto was to follow your philosophy and the ideas of the V1.

TL;DR : see my README

Console2

Instead of overriding nodejs console functions, I've built a new console from scratch and I've named it Console2. It allows us to use constructors logic and so to chain functions like this :

console.tag("My tag").time().file().log("My message")
//or in a hury
console.t("My tag").time().f().log("My message")

But, before all, you need to create the new Console2 instance. So, you have to do the following in order to have your new console operational :

var scribe = require('scribe')();
var console = scribe.console(/* pass options if you want */);

So, with just this line, you can use a brand new console instead of the old NodeJS one and keep using the console keyword. Of course you can still use colorsjs for your messages. See also the "Using Scribe through your modules" part of the README.

WebPanel I've work on the web panel too. A GIF worths 1000 words : webPanel demo Notice that it answers #5 (view all logs at once).

ExpressLogger The express logger hasn't change a lot.

LogWriter I've put all the save-in-files logic in a LogWriter object. There is a big change (maybe the biggest) : I know save logs in JSON. I've switch to JSON as it's much more suitable for the WebPanel. I also thought that, with a modular system like Scribe.js v2 is becoming, people could build CLI tools to print logs file in a human-readable format it they don't want to use the WebPanel.

Please tell me what you think of my work. I'm quite excited as I think the v2 managed to keep your ideas of a lightweight NodeJS logging while becoming more modular and more maintainable. I've also try to rigorously write doc, comments and examples. I've not written tests for now as it's something I've to learn first.

I really think Scribe.js has killer features that the NodeJS world could appreciate (keep console keyword, chaining functions, pretty console logging, the webPanel, events, no db).

PS : please excuse my grammar as I'm not english-native.

mathew-kurian commented 9 years ago

Thanks for all the support! It looks really good! I really love how you broke down the static page

guillaumewuip commented 9 years ago

Thanks @bluejamesbond. I just want to warn you that I haven't test Scribe v2 on prod yet but I remain available and I volunteer to maintain this beta in the coming days :bowtie: