Permalink
Browse files

Initial commit.

  • Loading branch information...
0 parents commit 9f16b0040344d24a4971133d7d4ab50db6d99e1d @scottgonzalez committed Aug 10, 2012
Showing with 70 additions and 0 deletions.
  1. +1 −0 .gitignore
  2. +31 −0 README.md
  3. +30 −0 logger.js
  4. +8 −0 package.json
@@ -0,0 +1 @@
+node_modules
@@ -0,0 +1,31 @@
+# node-logger
+
+A simple logger for node.js.
+
+## Installation
+
+```sh
+npm install git://github.com/jquery/node-logger.git
+```
+
+*Note: This module is very basic and is only intended to standardize logging
+within jQuery projects, so this is not versioned or published on npm.*
+
+## Usage
+
+```js
+var logger = require( "logger" ).init( "appname" );
+logger.log( "hello" );
+```
+
+The logger will log to syslog by default. If the main script is executed with
+`--console` then the logger will log to the console, allowing for easier
+testing during development.
+
+## API
+
+The logger supports three methods:
+
+* `logger.log( msg )`
+* `logger.warn( msg )`
+* `logger.error( msg )`
@@ -0,0 +1,30 @@
+if ( process.argv.indexOf( "--console" ) !== -1 ) {
+ module.exports = {
+ init: function() {
+ return console;
+ }
+ };
+ return;
+}
+
+var syslog = require( "node-syslog" );
+
+module.exports = {
+ init: function( name ) {
+ syslog.init( name, syslog.LOG_PID, syslog.LOG_LOCAL0 );
+
+ return {
+ log: function( msg ) {
+ syslog.log( syslog.LOG_INFO, msg );
+ },
+
+ warn: function( msg ) {
+ syslog.log( syslog.LOG_NOTICE, msg );
+ },
+
+ error: function( msg ) {
+ syslog.log( syslog.LOG_ERR, msg );
+ }
+ };
+ }
+};
@@ -0,0 +1,8 @@
+{
+ "name": "logger",
+ "version": "0.0.0",
+ "dependencies": {
+ "node-syslog": "1.1.6"
+ },
+ "main": "logger.js"
+}

0 comments on commit 9f16b00

Please sign in to comment.