New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

fm-log

Package Overview
Dependencies
Maintainers
1
Versions
39
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fm-log - npm Package Compare versions

Comparing version 0.3.0 to 0.4.0

.idea/codeStyleSettings.xml

18

demo.js

@@ -1,21 +0,23 @@

var log = require( __dirname + "/lib/log.js" ).module( "demo" );
// Grab module name automatically
log = require( __dirname + "/lib/log.js" ).module();
log.error( "ouch" );
log.info( "Logging without source tracing" );
// Basic logging
log = require( __dirname + "/lib/log.js" ).module( "demo" );
log.notice( "Initializing application...\nwow\nsuch application" );
log.critical( new Error( "Logging an Error instance." ) );
// Logging with source trace
log.withSource();
log.info( "Logging WITH source tracing" );
log.verbose( "Logging WITH source tracing" );
log.notice( "You'll never know where this was logged from!" );
// No prefix
log = require( __dirname + "/lib/log.js" );
log.warn( "We don't need no prefix!" );
// Adjusting to longer prefix
log = require( __dirname + "/lib/log.js" ).module( "something weird" );
log.warn( "...or do we?" );
log = require( __dirname + "/lib/log.js" );
log.notice( "You're using a longer prefix? I'll adjust." );
log = require( __dirname + "/lib/log.js" ).module();
log.error( "ouch" );
log.notice( "You're using a longer prefix? I'll adjust." );

@@ -48,3 +48,3 @@ "use strict";

var shouldLog = function( level, logger, message ) {
if( lastMessage&& message == lastMessage.message && level == lastMessage.level && logger == lastMessage.logger ) {
if( lastMessage && message == lastMessage.message && level == lastMessage.level && logger == lastMessage.logger ) {
++lastMessageRepeated;

@@ -314,2 +314,26 @@ return false;

/**
* Create and wrap a morgan instance.
* @param {Object} [options] The options object that will be passed to the morgan constructor.
* @param {Function} [how] How to log the output provided by morgan. Usually something like log.info.bind( log )
* @returns {Function} The middleware that can be placed in the express pipeline. Also has a "morgan" member, referencing the actual morgan instance.
*/
Logger.prototype.morgan = function( options, how ) {
how = how || this.debug.bind( this );
var Stream = require( "stream" ).Writable;
var logStream = new Stream();
logStream.write = function( data ) {
// Remove trailing newline
data = data.slice( 0, data.length - 1 );
how( data );
};
options.stream = logStream;
var morgan = require( "morgan" )( options );
// morgan, morgan, morgan, morgan
morgan.morgan = morgan;
return function( req, res, next ) {
morgan( req, res, next );
}
};
/**
* Construct a new Logger instance for a module with the given name.

@@ -316,0 +340,0 @@ * @param {String} [moduleName] The name of the module.

{
"name": "fm-log",
"version": "0.3.0",
"version": "0.4.0",
"description": "Console logging facility for Node",

@@ -5,0 +5,0 @@ "main": "lib/log.js",

@@ -11,33 +11,33 @@ fm-log

- sends everything straight to `console.log`, no events, no `nextTick()`
- condenses repeated messages like:
- condenses repeated messages
- displays stack traces for logged Error instances and other multi-line content nicely
- optionally displays the source of the logging call
2014-04-24 17:17:00.138 [DEBUG ] ( api-mobile.js) Cleaning up messages...
2014-04-24 17:34:32.715 [DEBUG ] ( api-mobile.js) Last message repeated 17 times.
2014-04-24 17:34:32.715 [INFO ] ( api-person.js) API-REQUEST: List Person...
Example
-------
- displays stack traces for logged Error instances and other multi-line content like:
```js
var log = require( __dirname + "/lib/log.js" ).module( "demo" );
![](img/example2.png)
log.info( "Logging without source tracing" );
log.notice( "Initializing application...\nwow\nsuch application" );
log.critical( new Error( "Logging an Error instance." ) );
- displays the source of the logging call when included like:
log.withSource();
log.info( "Logging WITH source tracing" );
log.notice( "You'll never know where this was logged from!" );
var log = require().withSource();
var log = require().module().withSource();
log = require( __dirname + "/lib/log.js" );
log.warn( "We don't need no prefix!" );
Example
-------
log = require( __dirname + "/lib/log.js" ).module( "something weird" );
log.warn( "...or do we?" );
var log = require( "fm-log" ).module();
log.info( "Initializing application..." );
log.debug( "We be logging" );
log.info( "We be logging" );
log.notice( "We be logging" );
log.warn( "We be warning" );
log.error( "We be logging" );
log.critical( "We be logging" );
var generic = require( "fm-log" );
generic.notice( "We don't need no prefix" );
log = require( __dirname + "/lib/log.js" );
log.notice( "You're using a longer prefix? I'll adjust." );
log = require( __dirname + "/lib/log.js" ).module();
log.error( "ouch" );
```
![](img/example.png)

@@ -48,2 +48,6 @@

Install
npm install fm-log
Put this in every file where you want to log:

@@ -50,0 +54,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc