- Highly Configurable
- Module based Log Names
- Different module can be given a name to make it easier to find the culprit
- Buffered Output
- Allows you to ship the logs off to the local sawmill or whittle a cat out of them
- Buffers are currently, per instance
- Customizable Log Format
- Standard output across all parts of your application
- Schemas Based on Environments
- NodeJs Only (sorry browser people)
- Groups (pretty trees O^O)
- Colors (double rainbows!)
- Optional All Logs Synchronise
- Warning: current version errors are sent to stdout NOT stderr
- All Logs with Trace Information
- [/] Improve code quality
-
Create test framework
- Spawn a process to run the tests and compare the output
- Use examples as first set of tests
- Add code coverage (istanbul + coveralls)
- Add static analysis of code
-
Create test framework
- A String version of the Customizable Log Format
-
Custom Log Type (eg.
stumpy.cheese({shape:'block',color:'yellow'})) - Customizable Log Format per Log Type
- Transports for both NodeJs and Browser
- Fix NodeJs Logs Synchronise to send output errors using stderr (small buffer?)
- Global and per instance Buffers
$ npm install stumpy$ bower install stumpyvar stumpy = Stumpy();
stumpy.log("look for prey");
stumpy.info("sleep %f hours", 8.62);
stumpy.warn("kill %d mice in a day", 26);
stumpy.error("miss target");The first argument can be either an options Object or a name string followed by an options object.
The all options have defaults.
-
name- String used to when displaying a log. Default:"". -
env- String used to determine schema to use. which Default:"dev". -
replaceConsole- Boolean to enable/disable replace theconsoleglobal object with Stumpy. Default:false. -
getTrace- Boolean to enable/disable capture the trace info for each log. Default:false. -
showTrace- Boolean to enable/disable display of the trace info on each log. If this is set totrue,getTracewill be set totrue. Default:false. -
showDateTime- Boolean to enable/disable display of the date and time on each log. Default:falseif Broweser,trueif NodeJS. -
showLogId- Boolean to enable/disable display of the log id. The Id's are unique for each log per session, when the browser/server restarts the Id is reset. Default:false. -
showLogType- Boolean to enable/disable display of the log type ('log', 'warn', 'error', 'info', 'trace', 'group', or 'groupEnd'). Default:false. -
syncLogs- Boolean to enable/disable display of the synchronous logs. Warning: current version errors are sent to stdout NOT stderr. Default:false. -
display- Boolean or Object. If set totrue, all display options are set to true. The Object is a key:value map of all the logging types. Default:{ log: true, info: true, warn: true, error: true, trace: true, group: true, groupEnd: true } -
formatFunc(log<Object>, logInstanceOptions<Object>)- The Function used to format the logs whengetBuffer,onHandlers.addLogandonHandlers.delLogis called or on all log output. Default: built in function for server and browser. -
dateStringFunc(date<Date Object>)- This Function formats the data object to a string for logging. Default: built in DateString function. -
onHandlers- An Object. See Event Handler Options -
colors- An Object. See Colors Options -
group- An Object. See Group Options -
buffer- An Object. See Buffer Options -
schema- An Object. See Schema Options
-
log(...)- Add/display a log. See console.log Options -
warn(...)- Add/display a warning. See console.warn Options -
error(...)- Add/display a error. See console.error Options -
info(...)- Add/display a info. See console.info Options -
trace(...)- Add/display a trace. See console.trace Options -
group([name])- Add/display a group. Optionalname(default:group). -
groupEnd([name])- Add/display a groupEnd. Optionalname(default: samenameas group). -
clearBuffer()- Clears the in memory buffer. -
getBuffer()- Returns an Array of Strings after running each log thought thebuffer.formatFunc. Warning browser users:getBuffer()may not return expected results unless you include the sprintf library. -
getRawBuffer()- Returns the raw buffer (Array of Objects) with all the captured data. -
printBuffer()- Prints each log in the buffer using theformatFunc. -
setEnv()- Sets the current environment and applies the schema. -
getOptions()- Returns all current options (including schema) with environment applied. -
setOptions(options)- Merges/applies options on current options, if env is set it will applied the environment schema.
See Cli-Color for color values The all options have defaults.
-
log- String or Cli-Color Object. Default:"whiteBright" -
info- String or Cli-Color Object. Default:"blue" -
warn- String or Cli-Color Object. Default:"yellow" -
error- String or Cli-Color Object. Default:"red" -
trace- String or Cli-Color Object. Default:"magenta" -
group- String or Cli-Color Object. Default:"green" -
groupEnd- String or Cli-Color Object. Default:"green"
Used to generate the Group Trees for NodeJS The all options have defaults.
-
autoIndent- Boolean value enabling/disabling Group Trees. Default:true -
indent- Object containing the string parts used to the Group Tree for NodeJS
Used to configure the buffer. The all options have defaults.
-
size- Integer size of the log buffer. A0size will disable the buffer. When the limit is reached and a new log is add stumpy will remove the oldest log. Default:0. -
formatFunc(log<Object>, logInstanceOptions<Object>)- The function used to format the logs whengetBufferis called. If you wish to get the unformatted buffer usegetRawBuffer. Default:null. -
getTrace- Boolean to enable/disable capture of trace info on each log. Default:false. -
showTrace- Boolean to enable/disable show trace info on each log.getTracewill be set to true if this is set to true. Default:false. -
deepCopy- Boolean to enable/disable deep copy of objects stored in the buffer. The default is false to consume less memory, however objects are referenced so they could change from the original log. Default:false.
Used to configure the environment schemas. This is an object of environments, default: dev,stage, and prod.
When an env string is set, all keys in the matching schema key are applied over all other options in the base options.
The all options have defaults.
-
dev- An Object for thedevenvironment. Default:display: { log: true, info: true, warn: true, error: true, trace: true, group: true, groupEnd: true }. -
stage- An Object for thestageenvironment. Default:display: { log: false, info: false, warn: true, error: true, trace: true, group: true, groupEnd: true }. -
prod- An Object for theprodenvironment. Default:display: { log: false, info: false, warn: false, error: true, trace: true, group: false, groupEnd: false }.
The all options have defaults of no handlers.
-
addLog(logStr<String>, logObj<Object>)- A Function that will be called when a log is added. It will call the function formatting the logStr usingoptions.formatFunc. Default:null. -
delLog(logStr<String>, logObj<Object>)- A Function that will be called when a log is deleted from the Buffer. It will call the function formatting the logStr usingoptions.formatFunc. Default:null. -
addBuffer(logStr<String>, logObj<Object>)- A Function that will be called when a log is added. It will call the function formatting the logStr usingoptions.buffer.formatFunc. Default:null. -
delBuffer(logStr<String>, logObj<Object>)- A Function that will be called when a log is deleted from the Buffer. It will call the function formatting the logStr usingoptions.buffer.formatFunc. Default:null.
- NodeJS example using Replace Console, Sync Logs, Show Trace, Show Log Id and Show Log Type
- NodeJS example using Custom Formatting and Event Handlers
MIT: what else?
$ npm test$ npm run-script test-browser


