Skip to content

Commit

Permalink
log level
Browse files Browse the repository at this point in the history
  • Loading branch information
openhoat committed Dec 6, 2015
1 parent 2937332 commit 415a458
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
30 changes: 15 additions & 15 deletions lib/entity.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ Entity.findIdsByIndex = function (name, value) {
return p.do(
function () {
var index, k;
logger.enabledLevels.info && log.info('searching %s entity ID with index "%s" matching "%s"', type, name, value);
logger.enabledLevels.debug && log.debug('searching %s entity ID with index "%s" matching "%s"', type, name, value);
index = clazz.indexes && clazz.indexes[name];
if (!index) {
logger.enabledLevels.debug && log.debug('no index "%s" for entity "%s"', name, type);
Expand All @@ -66,7 +66,7 @@ Entity.findIdsByIndex = function (name, value) {
if (result) {
return result;
}
logger.enabledLevels.info && log.info('searching %s entity ID with link "%s" matching "%s"', type, name, value);
logger.enabledLevels.debug && log.debug('searching %s entity ID with link "%s" matching "%s"', type, name, value);
link = clazz.links && clazz.links[name];
if (!link) {
logger.enabledLevels.debug && log.debug('no link "%s" for entity "%s"', name, type);
Expand Down Expand Up @@ -94,7 +94,7 @@ Entity.list = function (sort) {
, type = clazz.type;
return p.do(
function () {
logger.enabledLevels.info && log.info('loading "%s" entities', type);
logger.enabledLevels.debug && log.debug('loading "%s" entities', type);
return ohm.exec('keys', ohm.toHash(type, '*'))
.then(function (keys) {
return p.map(keys, function (k) {
Expand All @@ -113,7 +113,7 @@ Entity.load = function (id) {
var clazz = this
, type = clazz.type
, entity, k;
logger.enabledLevels.info && log.info('loading "%s" entity from #%s', type, id);
logger.enabledLevels.debug && log.debug('loading "%s" entity from #%s', type, id);
return p.do(
function () {
k = ohm.toHash(type, id);
Expand Down Expand Up @@ -170,7 +170,7 @@ Entity.prototype.checkIndexes = function () {
type = entity.type;
schema = entity.getSchema();
id = entity.getId();
logger.enabledLevels.info && log.info('checking indexes for entity "%s" #%s', type, id);
logger.enabledLevels.debug && log.debug('checking indexes for entity "%s" #%s', type, id);
return entity.iterateIndexes(function (index, name, k) {
if (!index.unique) {
return;
Expand All @@ -187,7 +187,7 @@ Entity.prototype.checkIndexes = function () {
});
},
function () {
logger.enabledLevels.info && log.info('checking links for entity "%s" #%s', type, id);
logger.enabledLevels.debug && log.debug('checking links for entity "%s" #%s', type, id);
return entity.iterateLinks(function (link, name, k, reverseK, value) {
if (!link.unique && !link.reverseUnique) {
return;
Expand Down Expand Up @@ -242,7 +242,7 @@ Entity.prototype.delete = function (multi) {
}
type = entity.type;
clazz = entity.getClass();
logger.enabledLevels.info && log.info('deleting "%s" entity #%s', type, id);
logger.enabledLevels.debug && log.debug('deleting "%s" entity #%s', type, id);
},
function removeRefs() {
return entity.removeLinks(localMulti)
Expand All @@ -264,7 +264,7 @@ Entity.prototype.generateId = function () {
type = entity.type;
schema = ohm.getSchema(type);
idName = ohm.getSchemaId(type);
logger.enabledLevels.info && log.info('generating ID for entity type "%s"', type);
logger.enabledLevels.debug && log.debug('generating ID for entity type "%s"', type);
if (typeof entity[idName] !== 'undefined') {
return;
}
Expand Down Expand Up @@ -394,7 +394,7 @@ Entity.prototype.loadLinks = function () {
return p.do(function () {
type = entity.type;
id = entity.getId();
logger.enabledLevels.info && log.info('loading links for entity "%s" #%s', type, id);
logger.enabledLevels.debug && log.debug('loading links for entity "%s" #%s', type, id);
return entity.iterateLinks(false, function (link, name, k) {
return p.do(function loadLinksFromEntity() {
return ohm.exec(link.unique ? 'get' : 'smembers', k)
Expand All @@ -418,7 +418,7 @@ Entity.prototype.removeIndexes = function (multi) {
if (!clazz.indexes) {
return;
}
logger.enabledLevels.info && log.info('removing indexes for entity "%s" #%s', type, id);
logger.enabledLevels.debug && log.debug('removing indexes for entity "%s" #%s', type, id);
return entity
.iterateIndexes(function (index, name, k) {
if (index.unique) {
Expand All @@ -438,7 +438,7 @@ Entity.prototype.removeLinks = function (multi) {
return p.do(function () {
type = entity.type;
id = entity.getId();
logger.enabledLevels.info && log.info('removing links for entity "%s" #%s', type, id);
logger.enabledLevels.debug && log.debug('removing links for entity "%s" #%s', type, id);
return entity
.iterateLinks(function (link, name, k, reverseK, value) {
return p.do(
Expand Down Expand Up @@ -473,7 +473,7 @@ Entity.prototype.save = function (multi) {
clazz = entity.getClass();
type = entity.type;
id = entity.getId();
logger.enabledLevels.info && log.info('saving new "%s" entity', type);
logger.enabledLevels.debug && log.debug('saving new "%s" entity', type);
return p.do(function check() {
return ohm.validateSchema(entity.value, type, 'new')
.catch(function (err) {
Expand Down Expand Up @@ -535,7 +535,7 @@ Entity.prototype.saveIndexes = function (multi) {
if (!clazz.indexes) {
return;
}
logger.enabledLevels.info && log.info('saving indexes for entity "%s" #%s', type, id);
logger.enabledLevels.debug && log.debug('saving indexes for entity "%s" #%s', type, id);
return entity
.iterateIndexes(function (index, name, k) {
if (index.unique) {
Expand All @@ -560,7 +560,7 @@ Entity.prototype.saveLinks = function (multi) {
return p.do(function () {
type = entity.type;
id = entity.getId();
logger.enabledLevels.info && log.info('saving links for entity "%s" #%s', type, id);
logger.enabledLevels.debug && log.debug('saving links for entity "%s" #%s', type, id);
return entity
.iterateLinks(function (link, name, k, reverseK, value) {
return p.do(
Expand Down Expand Up @@ -605,7 +605,7 @@ Entity.prototype.update = function (multi) {
type = entity.type;
clazz = entity.getClass();
id = entity.getId();
logger.enabledLevels.info && log.info('updating "%s" entity #%s', type, id);
logger.enabledLevels.debug && log.debug('updating "%s" entity #%s', type, id);
return ohm.validateSchema(entity.value, type, 'save')
.catch(function (err) {
e.throw('BAD_FORMAT', {schemaErrors: err});
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "hw-redis-ohm",
"version": "0.2.4",
"version": "0.2.5",
"description": "Redis Object Hash Mapping",
"main": "lib/ohm.js",
"author": "Olivier Penhoat <openhoat@gmail.com> (http://headwood.net/)",
Expand Down

0 comments on commit 415a458

Please sign in to comment.