diff --git a/README.md b/README.md index a5ce6fdbe6eedf865d52b900a9956cf271a66578..8fe141d7b89e633c6540ea2b88f0dab27e8ab68c 100644 --- a/README.md +++ b/README.md @@ -41,6 +41,6 @@ These Tags will be added to the line with octothorpes added. name: 'Name of App. Default: Name of BaseFolder', hostname: 'Server Hostname, Default: os.hostname()', file: 'File to Append Log to', - logLevel: 'Minimal LogLevel. Default: WARN' + loglevel: 'Minimal LogLevel. Default: WARN' } ``` \ No newline at end of file diff --git a/index.js b/index.js index 0bf88a14a6f6a19481766d5b8d8929746853e4b6..3bbb2a3ce4358f6a304100bd14b6008decf1e563 100644 --- a/index.js +++ b/index.js @@ -26,6 +26,13 @@ function Log (options) { } if (this.options.file) { this.fs = require('fs') + this.path = require('path') + this.options.file = this.path.resolve(this.options.file) + try { + this.fs.accessSync(this.options.file, this.fs.constants.R_OK | this.fs.constants.W_OK) + } catch (err) { + this.fs.writeFileSync(this.options.file, '') + } } this.info = function (message, tags) { if (this.loglevel >= this.levels.INFO) { diff --git a/package.json b/package.json index 36762a7978d5b1d6ef0e08ca2c0c7afe131f054f..8b85ad7a506ea53c958c940d7cb0f226857a4625 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "lib-log", - "version": "1.0.0", + "version": "1.1.0", "description": "A simple Logger with Options!", "main": "index.js", "scripts": {