diff --git a/.npm/package/npm-shrinkwrap.json b/.npm/package/npm-shrinkwrap.json index 0736d2a..31177ff 100644 --- a/.npm/package/npm-shrinkwrap.json +++ b/.npm/package/npm-shrinkwrap.json @@ -1,18 +1,18 @@ { "dependencies": { "fs-extra": { - "version": "0.28.0", - "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-0.28.0.tgz", - "from": "fs-extra@0.28.0", + "version": "0.30.0", + "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-0.30.0.tgz", + "from": "fs-extra@0.30.0", "dependencies": { "graceful-fs": { - "version": "4.1.3", - "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.1.3.tgz", + "version": "4.1.4", + "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.1.4.tgz", "from": "graceful-fs@>=4.1.2 <5.0.0" }, "jsonfile": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-2.3.0.tgz", + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-2.3.1.tgz", "from": "jsonfile@>=2.1.0 <3.0.0" }, "klaw": { @@ -36,13 +36,13 @@ "from": "glob@>=7.0.0 <8.0.0", "dependencies": { "inflight": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.4.tgz", + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.5.tgz", "from": "inflight@>=1.0.4 <2.0.0", "dependencies": { "wrappy": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.1.tgz", + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", "from": "wrappy@>=1.0.0 <2.0.0" } } @@ -58,14 +58,14 @@ "from": "minimatch@>=2.0.0 <3.0.0||>=3.0.0 <4.0.0", "dependencies": { "brace-expansion": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.3.tgz", + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.4.tgz", "from": "brace-expansion@>=1.0.0 <2.0.0", "dependencies": { "balanced-match": { - "version": "0.3.0", - "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-0.3.0.tgz", - "from": "balanced-match@>=0.3.0 <0.4.0" + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-0.4.1.tgz", + "from": "balanced-match@>=0.4.1 <0.5.0" }, "concat-map": { "version": "0.0.1", @@ -82,8 +82,8 @@ "from": "once@>=1.3.0 <2.0.0", "dependencies": { "wrappy": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.1.tgz", + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", "from": "wrappy@>=1.0.0 <2.0.0" } } diff --git a/.versions b/.versions index bb37ec9..6807c11 100644 --- a/.versions +++ b/.versions @@ -10,8 +10,8 @@ ejson@1.0.11 meteor@1.1.14 modules@0.6.1 modules-runtime@0.6.3 -ostrio:logger@1.1.1 -ostrio:loggerfile@1.1.1 +ostrio:logger@1.1.2 +ostrio:loggerfile@1.1.2 ostrio:meteor-root@1.0.3 promise@0.6.7 random@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/README.md b/README.md index aae1840..21370fb 100755 --- a/README.md +++ b/README.md @@ -33,11 +33,22 @@ Usage - `data` {*Object*} - `userId` {*String*} - set if user is logged in and package `accounts-base` is installed - Note: Do not forget `\r\n` at the end of record-line - - `path` {*String*} - Log's storage path, absolute, or relative to NodeJS process, note: do not use '~' (path relative to user)! + - `options.path` {*String*} - Log's storage path, absolute, or relative to NodeJS process, note: do not use '~' (path relative to user)! Example: ```javascript -this.log = new Logger(); // Initialize Logger +// Initialize Logger: +this.log = new Logger(); + +// Initialize LoggerFile and enable with default settings: +(new LoggerFile(log)).enable(); +``` + +Example 2: +```javascript +// Initialize Logger +this.log = new Logger(); + // Initialize LoggerFile: var LogFile = new LoggerFile(log, { fileNameFormat: function(time) { @@ -51,13 +62,14 @@ var LogFile = new LoggerFile(log, { path: '/data/logs/' /* Use absolute storage path */ }); -LogFile.enable(); // Enable LoggerFile with default settings +// Enable LoggerFile with default settings +LogFile.enable(); ``` ##### Activate and set adapter settings: [*Isomorphic*] ```javascript this.log = new Logger(); -new LoggerFile(log, {}).enable({ +(new LoggerFile(log)).enable({ enable: true, filter: ['ERROR', 'FATAL', 'WARN'], /* Filters: 'ERROR', 'FATAL', 'WARN', 'DEBUG', 'INFO', 'TRACE', '*' */ client: false, /* This allows to call, but not execute on Client */ @@ -68,7 +80,7 @@ new LoggerFile(log, {}).enable({ ##### Log message: [*Isomorphic*] ```javascript this.log = new Logger(); -new LoggerFile(log).enable(); +(new LoggerFile(log)).enable(); /* message {String} - Any text message @@ -105,9 +117,9 @@ window.onerror = function(msg, url, line) { this.log1 = new Logger(); this.log2 = new Logger(); -new LoggerFile(log1).enable(); +(new LoggerFile(log1)).enable(); -new LoggerFile(log2, { +(new LoggerFile(log2, { fileNameFormat: function(time) { return (time.getDate()) + "-" + (time.getMonth() + 1) + "-" + (time.getFullYear()) + "_" + (time.getHours()) + ".log"; }, @@ -115,5 +127,5 @@ new LoggerFile(log2, { return "[" + level + "] | " + (time.getMinutes()) + ":" + (time.getSeconds()) + " | \"" + message + "\" | User: " + userId + "\r\n"; }, path: '/data/logs/' -}).enable(); +})).enable(); ``` \ No newline at end of file diff --git a/loggerfile.coffee b/loggerfile.coffee index 5dcb3b8..a62ce27 100755 --- a/loggerfile.coffee +++ b/loggerfile.coffee @@ -9,7 +9,7 @@ if Meteor.isServer class LoggerFile constructor: (@logger, @options = {}) -> check @logger, Match.OneOf Logger, Object - check @options, Object + check @options, Match.Optional Object self = @ if Meteor.isServer @@ -87,9 +87,16 @@ class LoggerFile , true enable: (rule = {}) -> - check rule, Object + check rule, { + enable: Match.Optional Boolean + client: Match.Optional Boolean + server: Match.Optional Boolean + filter: Match.Optional [String] + } + rule.enable ?= true rule.client ?= false rule.server ?= true + @logger.rule 'File', rule return @ \ No newline at end of file diff --git a/package.js b/package.js index 0036f1a..db825fc 100755 --- a/package.js +++ b/package.js @@ -1,6 +1,6 @@ Package.describe({ name: 'ostrio:loggerfile', - version: '1.1.1', + version: '1.1.2', summary: 'Logging: Store application\'s logs into file (Server & Client support)', git: 'https://github.com/VeliovGroup/Meteor-logger-file', documentation: 'README.md' @@ -9,11 +9,11 @@ Package.describe({ Package.onUse(function(api) { api.versionsFrom('1.0'); api.use('ostrio:meteor-root@1.0.3', 'server') - api.use(['coffeescript', 'ostrio:logger@1.1.1', 'check', 'underscore'], ['client', 'server']); + api.use(['coffeescript', 'ostrio:logger@1.1.2', 'check', 'underscore'], ['client', 'server']); api.addFiles('loggerfile.coffee', ['client', 'server']); api.export('LoggerFile'); }); Npm.depends({ - 'fs-extra': '0.28.0' // NOTE: this package has dropped support for Node v0.10, since v0.29.0 + 'fs-extra': '0.30.0' // NOTE: this package has dropped support for Node v0.10, since v0.29.0; Brought back Node v0.10 support in v0.30.0, official support will end 2016-10-01 }); \ No newline at end of file