Skip to content

Commit

Permalink
Merge pull request #6 from keis/placeholder-array
Browse files Browse the repository at this point in the history
move placeholder object closer to a plain array
  • Loading branch information
keis committed Apr 24, 2015
2 parents 0ff196e + dbac02f commit 2fcaf32
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions lib/index.js
Expand Up @@ -142,7 +142,7 @@ Hierarchy.prototype.manageLogger = function (logger, placeholder) {
if (!obj) {
loggers[key] = new PlaceHolder(logger)
} else if (obj instanceof PlaceHolder) {
obj.add(logger)
obj.push(logger)
} else {
parent = obj
break
Expand All @@ -165,8 +165,8 @@ Hierarchy.prototype.manageLogger = function (logger, placeholder) {
, length
, i

for (i = 0, length = placeholder.loggers.length; i < length; i++) {
child = placeholder.loggers[i]
for (i = 0, length = placeholder.length; i < length; i++) {
child = placeholder[i]
// A sanity check that was present in python logging, the
// attributes of a case that triggers this is still unclear
if (child.parent.name.substring(0, name.length) !== name) {
Expand Down Expand Up @@ -238,18 +238,15 @@ function createHierarchy() {
return hier
}

// # Placeholder
// # PlaceHolder

// Constructor for logger placeholder that holds a list of child loggers that
// may need to be patched at a later time.
function PlaceHolder(logger) {
this.loggers = [logger]
this.push(logger)
}
PlaceHolder.prototype.push = Array.prototype.push

// Add a logger to the list of children
PlaceHolder.prototype.add = function (logger) {
this.loggers.push(logger)
}

// # Logger

Expand Down

0 comments on commit 2fcaf32

Please sign in to comment.