pax_global_header00006660000000000000000000000064124100477470014520gustar00rootroot0000000000000052 comment=e6c44109962cde39893862183a4252106e1a9a5b console.js-2.0.0/000077500000000000000000000000001241004774700135745ustar00rootroot00000000000000console.js-2.0.0/.gitignore000066400000000000000000000012111241004774700155570ustar00rootroot00000000000000# Compiled source # ################### *.com *.class *.dll *.exe *.o *.so # Packages # ############ # it's better to unpack these files and commit the raw source # git has its own built in compression methods *.7z *.dmg *.gz *.iso *.jar *.rar *.tar *.zip # Logs and databases # ###################### *.log *.sql *.sqlite # OS generated files # ###################### .DS_Store* ehthumbs.db Icon? Thumbs.db # Node.js # ########### lib-cov *.seed *.log *.csv *.dat *.out *.pid *.gz pids logs results node_modules npm-debug.log # Git # ####### *.orig *.BASE.* *.BACKUP.* *.LOCAL.* *.REMOTE.* # Components # ############## /build /components console.js-2.0.0/HISTORY.md000066400000000000000000000003531241004774700152600ustar00rootroot00000000000000 2.0.0 / 2014-09-22 ================== * `.log` signature changed to `(type, message, ...subsitutes?)` * `.fatal` uses the text `fatal` instead of `error` 1.1.1 / 2014-04-07 ================== * show stack traces for user errors console.js-2.0.0/README.md000066400000000000000000000023331241004774700150540ustar00rootroot00000000000000# Component Console Console commands for `component(1)`. Use this to create consistent logs across `component(1)` commands and libs. ## License (The MIT License) Copyright (c) 2014 segmentio <team@segment.io> Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. console.js-2.0.0/index.js000066400000000000000000000053711241004774700152470ustar00rootroot00000000000000var debug = require('debug')('component-consoler'); var slice = Array.prototype.slice; /** * Error types where we show the stack trace. * These are generally user errors, not "our" errors. **/ var showstack = [ 'ParseError', 'SyntaxError', 'URIError' ]; /** * Log message with `type` and `message` interpolated by `substitutes`. * * @param {String} type * @param {String} message * @param {...String} [substitutes] * @api public **/ exports.log = function (type, message /*, substitutes */) { log('log', 36, type, message, slice.call(arguments, 2)); }; /** * Log warning message with `type` and `message` interpolated by `substitutes`. * * @param {String} type * @param {String} message * @param {...String} [substitutes] * @api public **/ exports.warn = function (type, message /*, substitutes */) { log('warn', 33, type, message, slice.call(arguments, 2)); }; /** * Log error message with "error" type and `message` interpolated by `substitutes`. * * @param {String} message * @param {...String} [substitutes] * @api public **/ exports.error = function (message /*, substitutes */) { log('error', 31, 'error', message, slice.call(arguments, 1)); }; /** * Log error message and exit with "fatal" type and `error` interpolated by `substitutes`. * Depending on the error type, show the stack trace. * * @param {String|Error} error * @param {...String} [substitutes] * @api public **/ exports.fatal = function (error /*, substitutes */) { var message = error; if (error instanceof Error) { debug(error.stack); if (error.stack && ~showstack.indexOf(error.name)) { message = error.stack; } else { message = error.message; } } console.error(); log('error', 31, 'fatal', message, slice.call(arguments, 1)); console.error(); process.exit(1); }; /** * Log message in console `method` with `color`, `type`, `message`, `substitutes`. * * @param {String} method * @param {Number} color * @param {String} type * @param {String} message * @param {String[]} substitues * @api private **/ function log (method, color, type, message, substitutes) { console[method].apply(console, [stylize(type, message, color)].concat(substitutes)); } /** * Stylize message, use `color` for `type` before `message`. * * @param {String} type * @param {String} message * @param {Number} color * @return {String} * @api private **/ function stylize (type, message, color) { return ' \033[' + color + 'm' + pad(type) + '\033[m : \033[90m' + message + '\033[m'; } /** * Add whitespace indentation before text. * * @param {String} text * @return {String} * @api private **/ function pad (text) { var width = 10; var length = Math.max(0, width - text.length); var space = Array(length + 1).join(' '); return space + text; } console.js-2.0.0/package.json000066400000000000000000000003251241004774700160620ustar00rootroot00000000000000{ "name": "component-consoler", "description": "console commands for component(1)", "version": "2.0.0", "license": "MIT", "repository": "component/console.js", "dependencies": { "debug": "*" } } console.js-2.0.0/test/000077500000000000000000000000001241004774700145535ustar00rootroot00000000000000console.js-2.0.0/test/index.js000066400000000000000000000004311241004774700162160ustar00rootroot00000000000000var utils = require('..'); utils.log('user', 'seems like %s is a real %s', 'wryk', 'person'); utils.warn('addiction', 'take care about loving %s', 'component'); utils.error('simple %s stuff', 'useless'); utils.fatal(new Error('error message from error.message without stack :O'));