From f57ea35982cb5997218ef246794950f653f83842 Mon Sep 17 00:00:00 2001 From: Domink Sigmund <sigmund.dominik@googlemail.com> Date: Fri, 28 Sep 2018 09:58:09 +0200 Subject: [PATCH] Made Fabric to use multiple Instances --- README.md | 3 ++- index.js | 3 ++- samples/all-options.js | 4 +++- samples/log-to-file.js | 4 +++- samples/no-options.js | 4 +++- 5 files changed, 13 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index cfee573..811d0bb 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,8 @@ May Optional Log to A File and / or a Graylog-Server ## Usage -`const log = require('log')(options)` +`const Log = require('log')` +`let log = new Log(options)` Note: The options Part may be omitted, as all parts are optional, but using the name is recommended, as without it, the folder-name will be used diff --git a/index.js b/index.js index 46bcba5..0e0f98d 100644 --- a/index.js +++ b/index.js @@ -1,4 +1,4 @@ -module.exports = function (options) { +function Log (options) { this.moment = require('moment') this.path = require('path') this.fs = require('fs') @@ -68,3 +68,4 @@ module.exports = function (options) { } return this } +module.exports = Log diff --git a/samples/all-options.js b/samples/all-options.js index 96ab893..86411c5 100644 --- a/samples/all-options.js +++ b/samples/all-options.js @@ -1,4 +1,6 @@ -const log = require('../index.js')({ +const Log = require('../index.js') + +let log = new Log({ name: 'Sample-Application', hostname: 'test-server' }) diff --git a/samples/log-to-file.js b/samples/log-to-file.js index c2aaa18..8f35981 100644 --- a/samples/log-to-file.js +++ b/samples/log-to-file.js @@ -1,4 +1,6 @@ -const log = require('../index.js')({ +const Log = require('../index.js') + +let log = new Log({ name: 'Sample-File', file: 'file.log' }) diff --git a/samples/no-options.js b/samples/no-options.js index c1549b1..fe28ba6 100644 --- a/samples/no-options.js +++ b/samples/no-options.js @@ -1,4 +1,6 @@ -const log = require('../index.js')() +const Log = require('../index.js') + +let log = new Log() log.info('This is an Information') log.warn('This is a Warning') -- GitLab