diff --git a/index.js b/index.js index 2fb5b072251446a0b720b9cbff1938f60c705b05..b58f79c92d476ad30814129652c325f63b096668 100644 --- a/index.js +++ b/index.js @@ -26,6 +26,9 @@ function Log (options) { let os = require('os') this.hostname = os.hostname() } + if (this.options.graylog && this.options.graylog.active) { + this.udpclient = udp.createSocket('udp4') + } if (this.options.file) { this.fs = require('fs') this.path = require('path') @@ -34,9 +37,6 @@ function Log (options) { } catch (error) { throw new Error('Could not create path ' + this.options.path + '\n' + error.toString()) } - if (this.options.graylog && this.options.graylog.active) { - this.udpclient = udp.createSocket('udp4') - } try { this.fs.accessSync(this.path.join(this.options.path, this.options.file), this.fs.constants.R_OK | this.fs.constants.W_OK) } catch (err) {