├── .gitignore ├── LICENSE ├── README.md ├── index.js ├── package.json └── test.js /.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | 5 | # Runtime data 6 | pids 7 | *.pid 8 | *.seed 9 | 10 | # Directory for instrumented libs generated by jscoverage/JSCover 11 | lib-cov 12 | 13 | # Coverage directory used by tools like istanbul 14 | coverage 15 | 16 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) 17 | .grunt 18 | 19 | # node-waf configuration 20 | .lock-wscript 21 | 22 | # Compiled binary addons (http://nodejs.org/api/addons.html) 23 | build/Release 24 | 25 | # Dependency directory 26 | # https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git- 27 | node_modules 28 | .DS_Store 29 | .AppleDouble 30 | .LSOverride 31 | 32 | # Icon must end with two \r 33 | Icon 34 | 35 | 36 | # Thumbnails 37 | ._* 38 | 39 | # Files that might appear on external disk 40 | .Spotlight-V100 41 | .Trashes 42 | 43 | # Directories potentially created on remote AFP share 44 | .AppleDB 45 | .AppleDesktop 46 | Network Trash Folder 47 | Temporary Items 48 | .apdisk -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 egoist aprilorange.net@icloud.com 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # typelog 2 | 3 | [![NPM version](https://img.shields.io/npm/v/typelog.svg?style=flat-square)](https://www.npmjs.com/package/typelog) 4 | [![NPM download](https://img.shields.io/npm/dm/typelog.svg?style=flat-square)](https://www.npmjs.com/package/typelog) 5 | [![David Status](https://img.shields.io/david/egoist/typelog.svg?style=flat-square)](https://david-dm.org/egoist/typelog) 6 | 7 | Imagine logging everything in your console with a type. 8 | 9 | ![preview](https://ooo.0o0.ooo/2016/03/21/56f0c0988384a.png) 10 | 11 | ## Usage 12 | 13 | ```javascript 14 | const log = require('typelog') 15 | 16 | // exitCode: 0 17 | log.info('I\'m some information', 'hah?') 18 | log.warn('Please do not hate me') 19 | log.success('You finally got that girlfriend') 20 | 21 | // exitCode: 1 22 | log.error('You did something that wrong') 23 | 24 | // heading title 25 | log.heading('heading') 26 | //=> ❯❯❯❯❯ heading 27 | ``` 28 | 29 | ## License 30 | 31 | MIT © [EGOIST](https://github.com/egoist). 32 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | var chalk = require('chalk') 3 | var figures = require('figures') 4 | 5 | var log = module.exports = {} 6 | 7 | log.info = function () { 8 | var args = [].slice.call(arguments) 9 | args = [chalk.cyan(figures.info), chalk.cyan(fillString('Info'))].concat(args) 10 | process.exitCode = 0 11 | console.log.apply(console.log, args) 12 | } 13 | 14 | log.error = function () { 15 | var args = [].slice.call(arguments) 16 | args = [chalk.red(figures.cross), chalk.red(fillString('Error'))].concat(args) 17 | process.exitCode = 1 18 | console.log.apply(console.log, args) 19 | } 20 | 21 | log.warn = function () { 22 | var args = [].slice.call(arguments) 23 | args = [chalk.yellow(figures.warning), chalk.yellow(fillString('Warn'))].concat(args) 24 | process.exitCode = 0 25 | console.log.apply(console.log, args) 26 | } 27 | 28 | log.success = function () { 29 | var args = [].slice.call(arguments) 30 | args = [chalk.green(figures.tick), chalk.green(fillString('Success'))].concat(args) 31 | process.exitCode = 0 32 | console.log.apply(console.log, args) 33 | } 34 | 35 | log.heading = function () { 36 | var args = [].slice.call(arguments) 37 | args = [chalk.cyan(figures.pointer.repeat(5))].concat(args) 38 | process.exitCode = 0 39 | console.log.apply(console.log, args) 40 | } 41 | 42 | function fillString(text, max) { 43 | text += ':' 44 | return text 45 | } 46 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "typelog", 3 | "version": "0.2.0", 4 | "description": "console.log with types", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "echo lol" 8 | }, 9 | "author": "EGOIST", 10 | "license": "MIT", 11 | "engine": { 12 | "node": ">= 0.10" 13 | }, 14 | "dependencies": { 15 | "chalk": "^1.1.1", 16 | "figures": "^1.4.0" 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /test.js: -------------------------------------------------------------------------------- 1 | // TODO: write real tests 2 | var log = require('./') 3 | 4 | log.info('wow') 5 | log.warn('please don\'t') 6 | log.success('fancy') 7 | log.error('oops') 8 | log.heading('Downloading...') 9 | --------------------------------------------------------------------------------