Skip to content

Commit

Permalink
Release 0.0.2
Browse files Browse the repository at this point in the history
  • Loading branch information
ruimarinho committed Dec 31, 2015
1 parent 4c56950 commit c90a2b7
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 29 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Changelog

## [0.0.2](https://github.com/seegno/debugnyan/tree/0.0.2) (2015-12-31)
[Full Changelog](https://github.com/seegno/debugnyan/compare/0.0.1...0.0.2)

**Merged pull requests:**

- Update dev dependencies [\#31](https://github.com/seegno/debugnyan/pull/31) ([ruimarinho](https://github.com/ruimarinho))

## [0.0.1](https://github.com/seegno/debugnyan/tree/0.0.1) (2015-07-13)
57 changes: 29 additions & 28 deletions dist/index.js
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
'use strict';

var _slicedToArray = (function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; })();
/**
* Module dependencies.
*/

'use strict';

exports.__esModule = true;

var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };

exports['default'] = debugnyan;

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = debugnyan;

var _bunyan = require('bunyan');

Expand All @@ -21,62 +18,66 @@ var _debug = require('debug');

var _debug2 = _interopRequireDefault(_debug);

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

/**
* Loggers.
*/

var loggers = Object.create(null);
const loggers = Object.create(null);

/**
* Default level.
*/

var level = _bunyan2['default'].FATAL + 1;
const level = _bunyan2.default.FATAL + 1;

/**
* Export `debugnyan`.
*/

function debugnyan(name, options, config) {
var components = name.split(':');
var root = components[0];
const components = name.split(':');

var _components = _slicedToArray(components, 1);

const root = _components[0];

config = _extends({
config = Object.assign({
prefix: 'sub',
suffix: 'component'
}, config);

if (!loggers[root]) {
loggers[root] = _bunyan2['default'].createLogger(_extends({}, options, { name: root, level: level }));
loggers[root] = _bunyan2.default.createLogger(Object.assign({}, options, { level, name: root }));
}

var child = loggers[root];
let child = loggers[root];

for (var i = 1; i < components.length; i++) {
var _extends2;

var current = components[i];
var next = loggers[components.slice(0, i).join(':')];
var childName = components.slice(0, i + 1).join(':');
for (let i = 1; i < components.length; i++) {
const current = components[i];
const next = loggers[components.slice(0, i).join(':')];
const childName = components.slice(0, i + 1).join(':');

if (loggers[childName]) {
child = loggers[childName];

continue;
}

options = _extends({}, options, (_extends2 = {}, _extends2['' + config.prefix.repeat(i - 1) + config.suffix] = current, _extends2.level = level, _extends2));
options = Object.assign({}, options, {
level,
[`${ config.prefix.repeat(i - 1) }${ config.suffix }`]: current
});

child = next.child(options, true);

loggers[childName] = child;
}

if (_debug2['default'].enabled(name)) {
child.level(_bunyan2['default'].DEBUG);
if (_debug2.default.enabled(name)) {
child.level(_bunyan2.default.DEBUG);
}

return loggers[name];
}

module.exports = exports['default'];
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "debugnyan",
"version": "0.0.1",
"version": "0.0.2",
"description": "A logging library that combines the simplicity and convenience of debug with the power of bunyan",
"author": {
"email": "[email protected]",
Expand Down

0 comments on commit c90a2b7

Please sign in to comment.