From 406a189d745b3de6d8a013b450a9776445950701 Mon Sep 17 00:00:00 2001 From: "Dmitriy A. Golev" Date: Sat, 21 May 2016 00:17:27 +0300 Subject: [PATCH] v1.1.2 - Codebase fixes --- .versions | 2 +- LICENSE | 2 +- logger.coffee | 78 +++++++++++++++++++++++++++++---------------------- package.js | 2 +- 4 files changed, 47 insertions(+), 37 deletions(-) diff --git a/.versions b/.versions index 3004d17..3bf0270 100644 --- a/.versions +++ b/.versions @@ -10,7 +10,7 @@ ejson@1.0.11 meteor@1.1.14 modules@0.6.1 modules-runtime@0.6.3 -ostrio:logger@1.1.1 +ostrio:logger@1.1.2 promise@0.6.7 random@1.0.9 reactive-var@1.0.9 diff --git a/LICENSE b/LICENSE index d00d08d..b813e5f 100755 --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2016, dr.dimitru (Veliov Group LLC.) +Copyright (c) 2016, dr.dimitru (Dmitriy A.; Veliov Group, LLC) All rights reserved. Redistribution and use in source and binary forms, diff --git a/logger.coffee b/logger.coffee index ff50a58..02a0eb8 100755 --- a/logger.coffee +++ b/logger.coffee @@ -27,25 +27,25 @@ class Logger _log: (level, message, data = {}, user) => uid = user or @userId.get() for i, em of @_emitters - if @_rules[em.name] and @_rules[em.name].allow.indexOf('*') isnt -1 or @_rules[em.name] and @_rules[em.name].allow.indexOf(level) isnt -1 + if @_rules?[em.name] and @_rules[em.name].enable is true + if @_rules[em.name].allow.indexOf('*') isnt -1 or @_rules[em.name] and @_rules[em.name].allow.indexOf(level) isnt -1 + if level is "TRACE" + if _.isString data + _data = data + data = {data: _data} + data.stackTrace = @_getStackTrace() - if level is "TRACE" - if _.isString data - _data = data - data = {data: _data} - data.stackTrace = @_getStackTrace() - - if Meteor.isClient and em.denyClient is true - Meteor.call em.method, level, message, data, uid - else if @_rules[em.name].client is true and @_rules[em.name].server is true and em.denyClient is false - em.emitter level, message, data, uid - if Meteor.isClient + if Meteor.isClient and em.denyClient is true + Meteor.call em.method, level, message, data, uid + else if @_rules[em.name].client is true and @_rules[em.name].server is true and em.denyClient is false + em.emitter level, message, data, uid + if Meteor.isClient + Meteor.call em.method, level, message, data, uid + else if Meteor.isClient and @_rules[em.name].client is false and @_rules[em.name].server is true Meteor.call em.method, level, message, data, uid - else if Meteor.isClient and @_rules[em.name].client is false and @_rules[em.name].server is true - Meteor.call em.method, level, message, data, uid - else - em.emitter level, message, data, uid - + else + em.emitter level, message, data, uid + return new @_message level: level error: level @@ -73,29 +73,39 @@ class Logger @memberOf Logger @name rule @param name {String} - Adapter name - @param options {Object} - Settings object, accepts next properties: - enable {Boolean} - Enable/disable adapter - filter {Array} - Array of strings, accepts: - 'ERROR', 'FATAL', 'WARN', 'DEBUG', 'INFO', 'TRACE', 'LOG' and '*' - in lowercase or uppercase - default: ['*'] - Accept all - client {Boolean} - Allow execution on Client - server {Boolean} - Allow execution on Server + @param options {Object} - Settings object + options.enable {Boolean} - Enable/disable adapter + options.filter {Array} - Array of strings, accepts: + 'ERROR', 'FATAL', 'WARN', 'DEBUG', 'INFO', 'TRACE', 'LOG' and '*' + in lowercase or uppercase + default: ['*'] - Accept all + options.client {Boolean} - Allow execution on Client + options.server {Boolean} - Allow execution on Server @summary Enable/disable adapter and set it's settings ### rule: (name, options) => - if !name or !options or !options.enable - throw new Meteor.Error '500', '"name", "options" and "options.enable" is require on Logger.rule(), when creating rule for "' + name + '"' + check name, String + check options, { + enable: Boolean + client: Match.Optional Boolean + server: Match.Optional Boolean + filter: Match.Optional [String] + } + + if options.filter + for rule in options.filter + rule = rule.toUpperCase() - if options.allow - for k of options.allow - options.allow[k] = options.allow[k].toUpperCase() + options.filter ?= ['*'] + options.client ?= false + options.server ?= true + options.enable ?= true - @_rules[name] = + @_rules[name] = enable: options.enable - allow: if options.allow || options.filter then options.allow || options.filter else ['*'] - client: if options.client then options.client else false - server: if options.server then options.server else true + allow: options.filter + client: options.client + server: options.server return ### diff --git a/package.js b/package.js index 1a75a2d..4a47be8 100755 --- a/package.js +++ b/package.js @@ -1,6 +1,6 @@ Package.describe({ name: 'ostrio:logger', - version: '1.1.1', + version: '1.1.2', summary: 'Logging: isomorphic driver with support of MongoDB, File (FS) and Console', git: 'https://github.com/VeliovGroup/Meteor-logger', documentation: 'README.md'