Skip to content

Commit

Permalink
v1.6.0
Browse files Browse the repository at this point in the history
Updated NPM deps.

Improved readme docs.

Improved auto color selection with brightness range support.

Improved unit tests and code coverage.

Added various environment variables for globally defining default config settings.

Added explicit ns() method to create a namespaced logger.

Added namespace prefix when snooping on other loggers.
  • Loading branch information
cb1kenobi committed Jul 14, 2017
1 parent 14822e0 commit cacaf8e
Show file tree
Hide file tree
Showing 263 changed files with 530 additions and 59 deletions.
1 change: 1 addition & 0 deletions .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ docs
gulpfile.js
node_modules
npm-debug.log
scripts
yarn-error.log
src
test
30 changes: 28 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
[![Deps][david-image]][david-url]
[![Dev Deps][david-dev-image]][david-dev-url]

Laid back logging.
Laid back debug logging.

## Installation

Expand All @@ -21,6 +21,7 @@ Laid back logging.
* Pipe messages to one or more streams
* Namespacing
* Filter messages using the `DEBUG` (or `SNOOPLOGG`) environment variable
* Automatic color selection with brightness range
* Includes helper libraries for your convenience
* [chalk](https://www.npmjs.com/pacakge/chalk)
* [figures](https://www.npmjs.com/package/figures) (exported as `symbols`)
Expand Down Expand Up @@ -128,7 +129,32 @@ Creates a namespaced logger as well as defines the global namespaced logger.

Outputs a message using the standard `console.log()` format syntax.

*More docs to come in the future!*
#### `snooplogg.config(options)`

Allows you to set various instance specific options.

* `colors` - (Array) An array of color names to choose from when auto-selecting a color,
specifically for rendering the namespace.
* `minBrightness` - (Number) The minimum brightness to auto-select a color. Value must be between 0
and 255 as well as less than or equal to the `maxBrightness`. Defaults to `0`.
* `maxBrightness` - (Number) The maximum brightness to auto-select a color. Value must be between 0
and 255 as well as greater than or equal to the `minBrightness`. Defaults to `255`.
* `theme` - (String) The name of the default theme to use. Defaults to `standard`.
* `maxBufferSize` - (Number) The maximum number of log lines to buffer. Used to flush prior messages
to new pipes.

Returns the original `SnoopLogg` instance.

### Global Defaults

SnoopLogg allows you to set defaults using environment variables that apply to all SnoopLogg
instances.

* `SNOOPLOGG_COLOR_LIST` - A comma-separated list of supported color names.
* `SNOOPLOGG_DEFAULT_THEME` - Sets the `theme`.
* `SNOOPLOGG_MAX_BUFFER_SIZE` - Sets the `maxBufferSize`.
* `SNOOPLOGG_MAX_BRIGHTNESS` - Sets the `maxBrightness`.
* `SNOOPLOGG_MIN_BRIGHTNESS` - Sets the `minBrightness`.

## License

Expand Down
Binary file added lookup/0.br
Binary file not shown.
Binary file added lookup/1.br
Binary file not shown.
Binary file added lookup/10.br
Binary file not shown.
Binary file added lookup/100.br
Binary file not shown.
Binary file added lookup/101.br
Binary file not shown.
Binary file added lookup/102.br
Binary file not shown.
Binary file added lookup/103.br
Binary file not shown.
Binary file added lookup/104.br
Binary file not shown.
Binary file added lookup/105.br
Binary file not shown.
Binary file added lookup/106.br
Binary file not shown.
Binary file added lookup/107.br
Binary file not shown.
Binary file added lookup/108.br
Binary file not shown.
Binary file added lookup/109.br
Binary file not shown.
Binary file added lookup/11.br
Binary file not shown.
Binary file added lookup/110.br
Binary file not shown.
Binary file added lookup/111.br
Binary file not shown.
Binary file added lookup/112.br
Binary file not shown.
Binary file added lookup/113.br
Binary file not shown.
Binary file added lookup/114.br
Binary file not shown.
Binary file added lookup/115.br
Binary file not shown.
Binary file added lookup/116.br
Binary file not shown.
Binary file added lookup/117.br
Binary file not shown.
Binary file added lookup/118.br
Binary file not shown.
Binary file added lookup/119.br
Binary file not shown.
Binary file added lookup/12.br
Binary file not shown.
Binary file added lookup/120.br
Binary file not shown.
Binary file added lookup/121.br
Binary file not shown.
Binary file added lookup/122.br
Binary file not shown.
Binary file added lookup/123.br
Binary file not shown.
Binary file added lookup/124.br
Binary file not shown.
Binary file added lookup/125.br
Binary file not shown.
Binary file added lookup/126.br
Binary file not shown.
Binary file added lookup/127.br
Binary file not shown.
Binary file added lookup/128.br
Binary file not shown.
Binary file added lookup/129.br
Binary file not shown.
Binary file added lookup/13.br
Binary file not shown.
Binary file added lookup/130.br
Binary file not shown.
Binary file added lookup/131.br
Binary file not shown.
Binary file added lookup/132.br
Binary file not shown.
Binary file added lookup/133.br
Binary file not shown.
Binary file added lookup/134.br
Binary file not shown.
Binary file added lookup/135.br
Binary file not shown.
Binary file added lookup/136.br
Binary file not shown.
Binary file added lookup/137.br
Binary file not shown.
Binary file added lookup/138.br
Binary file not shown.
Binary file added lookup/139.br
Binary file not shown.
Binary file added lookup/14.br
Binary file not shown.
Binary file added lookup/140.br
Binary file not shown.
Binary file added lookup/141.br
Binary file not shown.
Binary file added lookup/142.br
Binary file not shown.
Binary file added lookup/143.br
Binary file not shown.
Binary file added lookup/144.br
Binary file not shown.
Binary file added lookup/145.br
Binary file not shown.
Binary file added lookup/146.br
Binary file not shown.
Binary file added lookup/147.br
Binary file not shown.
Binary file added lookup/148.br
Binary file not shown.
Binary file added lookup/149.br
Binary file not shown.
Binary file added lookup/15.br
Binary file not shown.
Binary file added lookup/150.br
Binary file not shown.
Binary file added lookup/151.br
Binary file not shown.
Binary file added lookup/152.br
Binary file not shown.
Binary file added lookup/153.br
Binary file not shown.
Binary file added lookup/154.br
Binary file not shown.
Binary file added lookup/155.br
Binary file not shown.
Binary file added lookup/156.br
Binary file not shown.
Binary file added lookup/157.br
Binary file not shown.
Binary file added lookup/158.br
Binary file not shown.
Binary file added lookup/159.br
Binary file not shown.
Binary file added lookup/16.br
Binary file not shown.
Binary file added lookup/160.br
Binary file not shown.
Binary file added lookup/161.br
Binary file not shown.
Binary file added lookup/162.br
Binary file not shown.
Binary file added lookup/163.br
Binary file not shown.
Binary file added lookup/164.br
Binary file not shown.
Binary file added lookup/165.br
Binary file not shown.
Binary file added lookup/166.br
Binary file not shown.
Binary file added lookup/167.br
Binary file not shown.
Binary file added lookup/168.br
Binary file not shown.
Binary file added lookup/169.br
Binary file not shown.
Binary file added lookup/17.br
Binary file not shown.
Binary file added lookup/170.br
Binary file not shown.
Binary file added lookup/171.br
Binary file not shown.
Binary file added lookup/172.br
Binary file not shown.
Binary file added lookup/173.br
Binary file not shown.
Binary file added lookup/174.br
Binary file not shown.
Binary file added lookup/175.br
Binary file not shown.
Binary file added lookup/176.br
Binary file not shown.
Binary file added lookup/177.br
Binary file not shown.
Binary file added lookup/178.br
Binary file not shown.
Binary file added lookup/179.br
Binary file not shown.
Binary file added lookup/18.br
Binary file not shown.
Binary file added lookup/180.br
Binary file not shown.
Binary file added lookup/181.br
Binary file not shown.
Binary file added lookup/182.br
Binary file not shown.
Binary file added lookup/183.br
Binary file not shown.
Binary file added lookup/184.br
Binary file not shown.
Binary file added lookup/185.br
Binary file not shown.
Binary file added lookup/186.br
Binary file not shown.
Binary file added lookup/187.br
Binary file not shown.
Binary file added lookup/188.br
Binary file not shown.
Binary file added lookup/189.br
Binary file not shown.
Binary file added lookup/19.br
Binary file not shown.
Binary file added lookup/190.br
Binary file not shown.
Binary file added lookup/191.br
Binary file not shown.
Binary file added lookup/192.br
Binary file not shown.
Binary file added lookup/193.br
Binary file not shown.
Binary file added lookup/194.br
Binary file not shown.
Binary file added lookup/195.br
Binary file not shown.
Binary file added lookup/196.br
Binary file not shown.
Binary file added lookup/197.br
Binary file not shown.
Binary file added lookup/198.br
Binary file not shown.
Binary file added lookup/199.br
Binary file not shown.
Binary file added lookup/2.br
Binary file not shown.
Binary file added lookup/20.br
Binary file not shown.
Binary file added lookup/200.br
Binary file not shown.
Binary file added lookup/201.br
Binary file not shown.
Binary file added lookup/202.br
Binary file not shown.
Binary file added lookup/203.br
Binary file not shown.
Binary file added lookup/204.br
Binary file not shown.
Binary file added lookup/205.br
Binary file not shown.
Binary file added lookup/206.br
Binary file not shown.
Binary file added lookup/207.br
Binary file not shown.
Binary file added lookup/208.br
Binary file not shown.
Binary file added lookup/209.br
Binary file not shown.
Binary file added lookup/21.br
Binary file not shown.
Binary file added lookup/210.br
Binary file not shown.
Binary file added lookup/211.br
Binary file not shown.
Binary file added lookup/212.br
Binary file not shown.
Binary file added lookup/213.br
Binary file not shown.
Binary file added lookup/214.br
Binary file not shown.
Binary file added lookup/215.br
Binary file not shown.
Binary file added lookup/216.br
Binary file not shown.
Binary file added lookup/217.br
Binary file not shown.
Binary file added lookup/218.br
Binary file not shown.
Binary file added lookup/219.br
Binary file not shown.
Binary file added lookup/22.br
Binary file not shown.
Binary file added lookup/220.br
Binary file not shown.
Binary file added lookup/221.br
Binary file not shown.
Binary file added lookup/222.br
Binary file not shown.
Binary file added lookup/223.br
Binary file not shown.
Binary file added lookup/224.br
Binary file not shown.
Binary file added lookup/225.br
Binary file not shown.
Binary file added lookup/226.br
Binary file not shown.
Binary file added lookup/227.br
Binary file not shown.
Binary file added lookup/228.br
Binary file not shown.
Binary file added lookup/229.br
Binary file not shown.
Binary file added lookup/23.br
Binary file not shown.
Binary file added lookup/230.br
Binary file not shown.
Binary file added lookup/231.br
Binary file not shown.
Binary file added lookup/232.br
Binary file not shown.
Binary file added lookup/233.br
Binary file not shown.
Binary file added lookup/234.br
Binary file not shown.
Binary file added lookup/235.br
Binary file not shown.
Binary file added lookup/236.br
Binary file not shown.
Binary file added lookup/237.br
Binary file not shown.
Binary file added lookup/238.br
Binary file not shown.
Binary file added lookup/239.br
Binary file not shown.
Binary file added lookup/24.br
Binary file not shown.
Binary file added lookup/240.br
Binary file not shown.
Binary file added lookup/241.br
Binary file not shown.
Binary file added lookup/242.br
Binary file not shown.
Binary file added lookup/243.br
Binary file not shown.
Binary file added lookup/244.br
Binary file not shown.
Binary file added lookup/245.br
Binary file not shown.
Binary file added lookup/246.br
Binary file not shown.
Binary file added lookup/247.br
Binary file not shown.
Binary file added lookup/248.br
Binary file not shown.
Binary file added lookup/249.br
Binary file not shown.
Binary file added lookup/25.br
Binary file not shown.
5 changes: 5 additions & 0 deletions lookup/250.br
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
LU�,��qL�fE��z�NZ����
$��R)���t�z�O�ă-Zx����t5���ì��=�Y�J��f���:�`Z�ú5,����aq�֝q`��b���y�{V����kaX�z‰��ak=�d-m T�I'Q��vp����$*���!�>�5�*,�:4ڧ>��V�eV�a'���sk|uX�~�_��HX�E���礟�ܸh�c�M�_A�/d�����3��)��<!S���w��U����� ��B&���彝w�� ]�M��H|�5�1��K|:�/�J�3.����&C�6%VA�+d:�x�Kh���v�� �2�m��-t�� Vu�M��
�>.d2G��\B�q;�`U��M��u��U�ὤ aHi�eI��!!U��"Q֡\҄2��)K rhȴ�xwT(kS�K�0��6eYA ��� mӎ�t���*�� ���I�2������q�1Xe@�2���CYg�c;�'Cd,3 tQ�*C�H:�u&/i1��x1D�)�
�)ʸ�v e���>ֲ���hS&
�B�0�mm��G,{i�ރU4�)�SAV�B&he��} mO����M� V1�EN���E�Q�鹤5��^�Yvcd����E2UVt���:�KZ����~t$
Expand Down
Binary file added lookup/251.br
Binary file not shown.
Binary file added lookup/252.br
Binary file not shown.
Binary file added lookup/253.br
Binary file not shown.
Binary file added lookup/254.br
Binary file not shown.
Binary file added lookup/255.br
Binary file not shown.
Binary file added lookup/26.br
Binary file not shown.
Binary file added lookup/27.br
Binary file not shown.
Binary file added lookup/28.br
Binary file not shown.
Binary file added lookup/29.br
Binary file not shown.
Binary file added lookup/3.br
Binary file not shown.
Binary file added lookup/30.br
Binary file not shown.
Binary file added lookup/31.br
Binary file not shown.
Binary file added lookup/32.br
Binary file not shown.
Binary file added lookup/33.br
Binary file not shown.
Binary file added lookup/34.br
Binary file not shown.
Binary file added lookup/35.br
Binary file not shown.
Binary file added lookup/36.br
Binary file not shown.
Binary file added lookup/37.br
Binary file not shown.
Binary file added lookup/38.br
Binary file not shown.
Binary file added lookup/39.br
Binary file not shown.
Binary file added lookup/4.br
Binary file not shown.
Binary file added lookup/40.br
Binary file not shown.
Binary file added lookup/41.br
Binary file not shown.
Binary file added lookup/42.br
Binary file not shown.
Binary file added lookup/43.br
Binary file not shown.
Binary file added lookup/44.br
Binary file not shown.
Binary file added lookup/45.br
Binary file not shown.
Binary file added lookup/46.br
Binary file not shown.
Binary file added lookup/47.br
Binary file not shown.
Binary file added lookup/48.br
Binary file not shown.
Binary file added lookup/49.br
Binary file not shown.
6 changes: 6 additions & 0 deletions lookup/5.br
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
�
���X]vH��#$�]dӘ�`��e:#�<�o��=���Eo�?����I�aa�����=�K 6`u��U����o^�6�q���vj�aZ�@i#W�R�"vʎ�� ����Z>w�ڈ��$\v�8�R�t�254;
 �g�'����Bڎ�&M45�0K�ҹR���x�$4 "|�5���B�N�xZsf!�Jg�.db��G�Lh���\��v$ӪX�(DRe*.�u�X��$A� )���M�e;5�0�����+�u����.Y��s���a$�?$��;\M�e�d�,�J�b�'������,���c7�5������/W}�5�0K�ҹx�T�����Нp�-���Ӳ��~�a�t&�B&�xd���p�-��40�UQ�Qp��$]$�ʾ�����/�b;5�0����q�-<���DK�o��,��O���ˮ��YR�ιC���E�-�}�L�}B���0K�s!S�cB#�e9�1���d��6̂f*��t!��x�� �:��x�kZ�6
Z�2^.Y�"]L[�V��ž�*�m�Se�]$��E����|� f����� �R>�E,G( �&�� ~�a�x���
��e<�Kh��S�݆Y��Jgt�� �����Po�VS���_�2z�H��,��@_����]���x<�Z��Y�ų,�gYl� �!UJo�"�Pʛ09�t`;_�(:Ǐ�)}��Ch(�7�^
�L�3�t!��в�\���,[/�}%�q_N$��,�/&4�/Dx����wRs�N�ﵖ�����@� U�?�EL?BY�?�ɁԠ��s�Anܯ�~�Z���Ș�B��g<�?�!�>��� �F0)�%&4���� �H0+�(3 8#:��/�E�E( �&��=���߸:nC]k9x�!'^h�_��M=Z�����^sa��i��2���h�e��2���e\ɢ�9G��:�dU�/[��l��d�E���x9�"Gx8_N�E����%� ��˝P��'x����3\��p�wv�'�1���
Expand Down
Binary file added lookup/50.br
Binary file not shown.
Binary file added lookup/51.br
Binary file not shown.
Binary file added lookup/52.br
Binary file not shown.
Binary file added lookup/53.br
Binary file not shown.
Binary file added lookup/54.br
Binary file not shown.
Binary file added lookup/55.br
Binary file not shown.
Binary file added lookup/56.br
Binary file not shown.
Binary file added lookup/57.br
Binary file not shown.
Binary file added lookup/58.br
Binary file not shown.
Binary file added lookup/59.br
Binary file not shown.
Binary file added lookup/6.br
Binary file not shown.
Binary file added lookup/60.br
Binary file not shown.
Binary file added lookup/61.br
Binary file not shown.
Binary file added lookup/62.br
Binary file not shown.
Binary file added lookup/63.br
Binary file not shown.
Binary file added lookup/64.br
Binary file not shown.
Binary file added lookup/65.br
Binary file not shown.
Binary file added lookup/66.br
Binary file not shown.
Binary file added lookup/67.br
Binary file not shown.
Binary file added lookup/68.br
Binary file not shown.
Binary file added lookup/69.br
Binary file not shown.
Binary file added lookup/7.br
Binary file not shown.
Binary file added lookup/70.br
Binary file not shown.
Binary file added lookup/71.br
Binary file not shown.
Binary file added lookup/72.br
Binary file not shown.
Binary file added lookup/73.br
Binary file not shown.
Binary file added lookup/74.br
Binary file not shown.
Binary file added lookup/75.br
Binary file not shown.
Binary file added lookup/76.br
Binary file not shown.
Binary file added lookup/77.br
Binary file not shown.
Binary file added lookup/78.br
Binary file not shown.
Binary file added lookup/79.br
Binary file not shown.
Binary file added lookup/8.br
Binary file not shown.
Binary file added lookup/80.br
Binary file not shown.
Binary file added lookup/81.br
Binary file not shown.
Binary file added lookup/82.br
Binary file not shown.
Binary file added lookup/83.br
Binary file not shown.
Binary file added lookup/84.br
Binary file not shown.
Binary file added lookup/85.br
Binary file not shown.
Binary file added lookup/86.br
Binary file not shown.
Binary file added lookup/87.br
Binary file not shown.
Binary file added lookup/88.br
Binary file not shown.
Binary file added lookup/89.br
Binary file not shown.
Binary file added lookup/9.br
Binary file not shown.
Binary file added lookup/90.br
Binary file not shown.
Binary file added lookup/91.br
Binary file not shown.
Binary file added lookup/92.br
Binary file not shown.
Binary file added lookup/93.br
Binary file not shown.
Binary file added lookup/94.br
Binary file not shown.
Binary file added lookup/95.br
Binary file not shown.
Binary file added lookup/96.br
Binary file not shown.
Binary file added lookup/97.br
Binary file not shown.
Binary file added lookup/98.br
Binary file not shown.
Binary file added lookup/99.br
Binary file not shown.
9 changes: 5 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "snooplogg",
"version": "1.5.0",
"version": "1.6.0",
"description": "Your mind on your logs and your logs on your mind",
"main": "./dist/index.js",
"author": "Chris Barber <chris@cb1inc.com> (https://github.com/cb1kenobi)",
Expand All @@ -24,14 +24,15 @@
"test": "gulp test"
},
"dependencies": {
"brotli": "^1.3.2",
"chalk": "^2.0.1",
"figures": "^2.0.0",
"humanize": "^0.0.9",
"moment": "^2.18.1",
"nanobuffer": "^1.0.0",
"pluralize": "^5.0.0",
"source-map-support": "^0.4.15",
"supports-color": "^4.1.0"
"supports-color": "^4.2.0"
},
"devDependencies": {
"babel-eslint": "^7.2.3",
Expand All @@ -40,7 +41,7 @@
"babel-plugin-transform-es2015-modules-commonjs": "^6.24.1",
"babel-plugin-transform-es2015-parameters": "^6.24.1",
"babel-plugin-transform-object-rest-spread": "^6.23.0",
"chai": "^4.0.2",
"chai": "^4.1.0",
"codeclimate-test-reporter": "^0.5.0",
"coveralls": "^2.13.1",
"del": "^3.0.0",
Expand All @@ -57,7 +58,7 @@
"gulp-mocha": "^3.0.1",
"gulp-plumber": "^1.1.0",
"gulp-sourcemaps": "^2.6.0",
"sinon": "^2.3.6",
"sinon": "^2.3.8",
"sinon-chai": "^2.11.0"
},
"homepage": "https://github.com/cb1kenobi/snooplogg",
Expand Down
76 changes: 76 additions & 0 deletions scripts/gen-brightness-lookup.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
/**
* This script generates lookup tables for the 'auto' style.
*/

const brotli = require('brotli');
const del = require('del');
const fs = require('fs');
const path = require('path');
const zlib = require('zlib');

const results = {};
const start = Date.now();
let brightness;
const outputDir = path.resolve(__dirname, '../lookup');
let totalBefore = 0;
let totalAfter = 0;

try {
fs.statSync(outputDir);
} catch (e) {
console.log('Creating lookup directory...');
fs.mkdirSync(outputDir);
}
const files = fs.readdirSync(outputDir);
if (files.length) {
console.log('Cleaning lookup directory...');
for (const name of files) {
fs.unlinkSync(path.join(outputDir, name));
}
}

console.log('Building lookup...');
for (let b = 0; b <= 255; b++) {
for (let g = 0; g <= 255; g++) {
for (let r = 0; r <= 255; r++) {
brightness = ((r * 299 + g * 587 + b * 114) / 1000) | 0;
if (!results[brightness]) {
results[brightness] = [];
}
results[brightness].push(r, g, b);
}
}
}

console.log('Writing lookup files...');
for (brightness of Object.keys(results)) {
let colors = results[brightness];
let before;
let after;

do {
before = Buffer.from(colors);
after = brotli.compress(before);
if (!after) {
// when brightness=255, there's only 1 color (3 bytes) and it's not enough bytes to make brotli happy
colors = colors.concat(colors.slice(0, 3));
}
} while (!after);

const blen = before.length;
const alen = after.length;

totalBefore += blen;
totalAfter += alen;

console.log('%s\t%s => %s\t(%s\%)', brightness, blen, alen, Math.round((blen - alen) / blen * 1000) / 10);

fs.writeFileSync(
`${outputDir}/${brightness}.br`,
after,
{ encoding: 'binary' }
);
}

console.log('Finished in %s ms', Date.now() - start);
console.log('%s bytes => %s bytes', totalBefore, totalAfter);
Loading

0 comments on commit cacaf8e

Please sign in to comment.