diff --git a/README.md b/README.md index cfee573759f79f865c8d256598b05eb686ee25c8..811d0bbb0f032e089bbd361e32bf672e9cec763f 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 46bcba50d4c30d0fd29407bca501b35da75ed4df..0e0f98d53ac03303db9f3e8cb2617546608a4730 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 96ab89362e78a05956448d5bd6094177c4ca8ff6..86411c564ca1feb09165d951fc25d9671c4c44d1 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 c2aaa183f6c94d867fb184030712aab8a1245c47..8f359816e57af37a9bf2afa3b7a858ed800c936a 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 c1549b1198b8fa20091bd037940f45e70fcb81af..fe28ba68f876b75f8b17ca26b825ca260e5d08f4 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')