From 3b5f30ab00d4a13d806f9f24ffbad066d819033d Mon Sep 17 00:00:00 2001
From: Dominik Sigmund <dominik.sigmund@br.de>
Date: Wed, 14 Nov 2018 13:58:54 +0100
Subject: [PATCH] Added LogLevel-Control

---
 index.js            |  49 ++-
 package.json        |   3 +-
 samples/use-tags.js |  20 +-
 tests/test.js       | 936 ++++++++++++++++++++++----------------------
 4 files changed, 523 insertions(+), 485 deletions(-)

diff --git a/index.js b/index.js
index c206a96..0bf88a1 100644
--- a/index.js
+++ b/index.js
@@ -1,5 +1,18 @@
 function Log (options) {
+  this.levels = {
+    'DEBUG': 5,
+    'INFO': 4,
+    'NOTICE': 3,
+    'WARN': 2,
+    'ERROR': 1,
+    'FATAL': 0
+  }
   this.options = options || {}
+  if (this.options.loglevel) { // DEBUG, INFO, NOTICE, WARN, ERROR, FATAL
+    this.loglevel = this.levels[this.options.loglevel]
+  } else {
+    this.loglevel = 2
+  }
   if (this.options.name) {
     this.name = this.options.name
   } else {
@@ -15,22 +28,46 @@ function Log (options) {
     this.fs = require('fs')
   }
   this.info = function (message, tags) {
-    return this.log('INFO', message, tags)
+    if (this.loglevel >= this.levels.INFO) {
+      return this.log('INFO', message, tags)
+    } else {
+      return ''
+    }
   }
   this.notice = function (message, tags) {
-    return this.log('NOTICE', message, tags)
+    if (this.loglevel >= this.levels.NOTICE) {
+      return this.log('NOTICE', message, tags)
+    } else {
+      return ''
+    }
   }
   this.fatal = function (message, tags) {
-    return this.log('FATAL', message, tags)
+    if (this.loglevel >= this.levels.FATAL) {
+      return this.log('FATAL', message, tags)
+    } else {
+      return ''
+    }
   }
   this.warn = function (message, tags) {
-    return this.log('WARN', message, tags)
+    if (this.loglevel >= this.levels.WARN) {
+      return this.log('WARN', message, tags)
+    } else {
+      return ''
+    }
   }
   this.error = function (message, tags) {
-    return this.log('ERROR', message, tags)
+    if (this.loglevel >= this.levels.ERROR) {
+      return this.log('ERROR', message, tags)
+    } else {
+      return ''
+    }
   }
   this.debug = function (message, tags) {
-    return this.log('DEBUG', message, tags)
+    if (this.loglevel >= this.levels.DEBUG) {
+      return this.log('DEBUG', message, tags)
+    } else {
+      return ''
+    }
   }
   this.log = function (tag, message, tags) {
     let tadd = ''
diff --git a/package.json b/package.json
index a08fc95..c757df7 100644
--- a/package.json
+++ b/package.json
@@ -4,7 +4,8 @@
   "description": "A simple Logger with Options!",
   "main": "index.js",
   "scripts": {
-    "test": "nyc --reporter=html --reporter=text mocha -- tests/test.js && rsync --remove-source-files -av --progress ./coverage ./docs/ && rm -Rf ./coverage",
+    "test" : "mocha tests/test.js",
+    "test-coverage": "nyc --reporter=html --reporter=text mocha -- tests/test.js && rsync --remove-source-files -av --progress ./coverage ./docs/ && rm -Rf ./coverage",
     "test-graphics": "nyc --reporter=html --reporter=text mocha -R mochawesome -- tests/test.js && rsync --remove-source-files -av --progress ./coverage ./docs/ && rm -Rf ./coverage  && rsync --remove-source-files -av --progress ./mochawesome-report ./docs/ && rm -Rf ./mochawesome-report"
   },
   "author": "Dominik Sigmund",
diff --git a/samples/use-tags.js b/samples/use-tags.js
index d59633f..32d82fa 100644
--- a/samples/use-tags.js
+++ b/samples/use-tags.js
@@ -1,10 +1,10 @@
-const Log = require('../index.js')
-
-let log = new Log()
-
-log.info('This is an Information', 'info')
-log.notice('This is a Notice', 'notice system ping')
-log.warn('This is a Warning', 'some,tags,added')
-log.error('This is an Error', ['tag', 'error', 'crit', 'api'])
-log.debug('This is a Debug Message')
-log.fatal('This is a Fatal Message')
+const Log = require('../index.js')
+
+let log = new Log()
+
+log.info('This is an Information', 'info')
+log.notice('This is a Notice', 'notice system ping')
+log.warn('This is a Warning', 'some,tags,added')
+log.error('This is an Error', ['tag', 'error', 'crit', 'api'])
+log.debug('This is a Debug Message')
+log.fatal('This is a Fatal Message')
diff --git a/tests/test.js b/tests/test.js
index aa8b745..ca0e4ed 100644
--- a/tests/test.js
+++ b/tests/test.js
@@ -1,468 +1,468 @@
-/* global it, describe, beforeEach, afterEach */
-const assert = require('assert')
-const os = require('os')
-const path = require('path')
-const fs = require('fs')
-const LOG = require(path.join(__dirname, '../index.js'))
-const hostname = os.hostname()
-function getDate () {
-  var tzoffset = (new Date()).getTimezoneOffset() * 60000 // offset in milliseconds
-  var localISOTime = (new Date(Date.now() - tzoffset)).toISOString().slice(0, -1)
-  return localISOTime.split('.')[0].trim()
-}
-const manualhostname = 'testhost'
-const name = 'testapp'
-const file = '/tmp/testfile'
-let log
-let line
-let testline
-describe('Log.js', function () {
-  describe(': No Options', function () {
-    beforeEach('create Object', function () {
-      log = new LOG()
-    })
-    afterEach('destroy Object', function () {
-      log = undefined
-    })
-    describe(': Info', function () {
-      it('should output the given Line', function () {
-        testline = getDate() + '\t' + hostname + '\tlog\tINFO\ttestline'
-        line = log.info('testline')
-        assert.equal(line, testline)
-      })
-      it('should output the given Line with Tags', function () {
-        testline = getDate() + '\t' + hostname + '\tlog\tINFO\ttestline #tag1 #tag2 #tag3'
-
-        line = log.info('testline', 'tag1 tag2 tag3')
-        assert.equal(line, testline)
-
-        line = log.info('testline', 'tag1,tag2,tag3')
-        assert.equal(line, testline)
-
-        line = log.info('testline', ['tag1', 'tag2', 'tag3'])
-        assert.equal(line, testline)
-      })
-    })
-    describe(': Notice', function () {
-      it('should output the given Line', function () {
-        testline = getDate() + '\t' + hostname + '\tlog\tNOTICE\ttestline'
-        line = log.notice('testline')
-        assert.equal(line, testline)
-      })
-      it('should output the given Line with Tags', function () {
-        testline = getDate() + '\t' + hostname + '\tlog\tNOTICE\ttestline #tag1 #tag2 #tag3'
-
-        line = log.notice('testline', 'tag1 tag2 tag3')
-        assert.equal(line, testline)
-
-        line = log.notice('testline', 'tag1,tag2,tag3')
-        assert.equal(line, testline)
-
-        line = log.notice('testline', ['tag1', 'tag2', 'tag3'])
-        assert.equal(line, testline)
-      })
-    })
-    describe(': Warn', function () {
-      it('should output the given Line', function () {
-        testline = getDate() + '\t' + hostname + '\tlog\tWARN\ttestline'
-        line = log.warn('testline')
-        assert.equal(line, testline)
-      })
-      it('should output the given Line with Tags', function () {
-        testline = getDate() + '\t' + hostname + '\tlog\tWARN\ttestline #tag1 #tag2 #tag3'
-
-        line = log.warn('testline', 'tag1 tag2 tag3')
-        assert.equal(line, testline)
-
-        line = log.warn('testline', 'tag1,tag2,tag3')
-        assert.equal(line, testline)
-
-        line = log.warn('testline', ['tag1', 'tag2', 'tag3'])
-        assert.equal(line, testline)
-      })
-    })
-    describe(': Error', function () {
-      it('should output the given Line', function () {
-        testline = getDate() + '\t' + hostname + '\tlog\tERROR\ttestline'
-        line = log.error('testline')
-        assert.equal(line, testline)
-      })
-      it('should output the given Line with Tags', function () {
-        testline = getDate() + '\t' + hostname + '\tlog\tERROR\ttestline #tag1 #tag2 #tag3'
-
-        line = log.error('testline', 'tag1 tag2 tag3')
-        assert.equal(line, testline)
-
-        line = log.error('testline', 'tag1,tag2,tag3')
-        assert.equal(line, testline)
-
-        line = log.error('testline', ['tag1', 'tag2', 'tag3'])
-        assert.equal(line, testline)
-      })
-    })
-    describe(': Fatal', function () {
-      it('should output the given Line', function () {
-        testline = getDate() + '\t' + hostname + '\tlog\tFATAL\ttestline'
-        line = log.fatal('testline')
-        assert.equal(line, testline)
-      })
-      it('should output the given Line with Tags', function () {
-        testline = getDate() + '\t' + hostname + '\tlog\tFATAL\ttestline #tag1 #tag2 #tag3'
-
-        line = log.fatal('testline', 'tag1 tag2 tag3')
-        assert.equal(line, testline)
-
-        line = log.fatal('testline', 'tag1,tag2,tag3')
-        assert.equal(line, testline)
-
-        line = log.fatal('testline', ['tag1', 'tag2', 'tag3'])
-        assert.equal(line, testline)
-      })
-    })
-    describe(': Debug', function () {
-      it('should output the given Line', function () {
-        testline = getDate() + '\t' + hostname + '\tlog\tDEBUG\ttestline'
-        line = log.debug('testline')
-        assert.equal(line, testline)
-      })
-      it('should output the given Line with Tags', function () {
-        testline = getDate() + '\t' + hostname + '\tlog\tDEBUG\ttestline #tag1 #tag2 #tag3'
-
-        line = log.debug('testline', 'tag1 tag2 tag3')
-        assert.equal(line, testline)
-
-        line = log.debug('testline', 'tag1,tag2,tag3')
-        assert.equal(line, testline)
-
-        line = log.debug('testline', ['tag1', 'tag2', 'tag3'])
-        assert.equal(line, testline)
-      })
-    })
-  })
-  describe(': Hostname Set', function () {
-    beforeEach('create Object', function () {
-      log = new LOG({
-        hostname: manualhostname
-      })
-    })
-    afterEach('destroy Object', function () {
-      log = undefined
-    })
-    describe(': Info', function () {
-      it('should output the given Line', function () {
-        testline = getDate() + '\t' + manualhostname + '\tlog\tINFO\ttestline'
-        line = log.info('testline')
-        assert.equal(line, testline)
-      })
-      it('should output the given Line with Tags', function () {
-        testline = getDate() + '\t' + manualhostname + '\tlog\tINFO\ttestline #tag1 #tag2 #tag3'
-
-        line = log.info('testline', 'tag1 tag2 tag3')
-        assert.equal(line, testline)
-
-        line = log.info('testline', 'tag1,tag2,tag3')
-        assert.equal(line, testline)
-
-        line = log.info('testline', ['tag1', 'tag2', 'tag3'])
-        assert.equal(line, testline)
-      })
-    })
-    describe(': Notice', function () {
-      it('should output the given Line', function () {
-        testline = getDate() + '\t' + manualhostname + '\tlog\tNOTICE\ttestline'
-        line = log.notice('testline')
-        assert.equal(line, testline)
-      })
-      it('should output the given Line with Tags', function () {
-        testline = getDate() + '\t' + manualhostname + '\tlog\tNOTICE\ttestline #tag1 #tag2 #tag3'
-
-        line = log.notice('testline', 'tag1 tag2 tag3')
-        assert.equal(line, testline)
-
-        line = log.notice('testline', 'tag1,tag2,tag3')
-        assert.equal(line, testline)
-
-        line = log.notice('testline', ['tag1', 'tag2', 'tag3'])
-        assert.equal(line, testline)
-      })
-    })
-    describe(': Warn', function () {
-      it('should output the given Line', function () {
-        testline = getDate() + '\t' + manualhostname + '\tlog\tWARN\ttestline'
-        line = log.warn('testline')
-        assert.equal(line, testline)
-      })
-      it('should output the given Line with Tags', function () {
-        testline = getDate() + '\t' + manualhostname + '\tlog\tWARN\ttestline #tag1 #tag2 #tag3'
-
-        line = log.warn('testline', 'tag1 tag2 tag3')
-        assert.equal(line, testline)
-
-        line = log.warn('testline', 'tag1,tag2,tag3')
-        assert.equal(line, testline)
-
-        line = log.warn('testline', ['tag1', 'tag2', 'tag3'])
-        assert.equal(line, testline)
-      })
-    })
-    describe(': Error', function () {
-      it('should output the given Line', function () {
-        testline = getDate() + '\t' + manualhostname + '\tlog\tERROR\ttestline'
-        line = log.error('testline')
-        assert.equal(line, testline)
-      })
-      it('should output the given Line with Tags', function () {
-        testline = getDate() + '\t' + manualhostname + '\tlog\tERROR\ttestline #tag1 #tag2 #tag3'
-
-        line = log.error('testline', 'tag1 tag2 tag3')
-        assert.equal(line, testline)
-
-        line = log.error('testline', 'tag1,tag2,tag3')
-        assert.equal(line, testline)
-
-        line = log.error('testline', ['tag1', 'tag2', 'tag3'])
-        assert.equal(line, testline)
-      })
-    })
-    describe(': Fatal', function () {
-      it('should output the given Line', function () {
-        testline = getDate() + '\t' + manualhostname + '\tlog\tFATAL\ttestline'
-        line = log.fatal('testline')
-        assert.equal(line, testline)
-      })
-      it('should output the given Line with Tags', function () {
-        testline = getDate() + '\t' + manualhostname + '\tlog\tFATAL\ttestline #tag1 #tag2 #tag3'
-
-        line = log.fatal('testline', 'tag1 tag2 tag3')
-        assert.equal(line, testline)
-
-        line = log.fatal('testline', 'tag1,tag2,tag3')
-        assert.equal(line, testline)
-
-        line = log.fatal('testline', ['tag1', 'tag2', 'tag3'])
-        assert.equal(line, testline)
-      })
-    })
-    describe(': Debug', function () {
-      it('should output the given Line', function () {
-        testline = getDate() + '\t' + manualhostname + '\tlog\tDEBUG\ttestline'
-        line = log.debug('testline')
-        assert.equal(line, testline)
-      })
-      it('should output the given Line with Tags', function () {
-        testline = getDate() + '\t' + manualhostname + '\tlog\tDEBUG\ttestline #tag1 #tag2 #tag3'
-
-        line = log.debug('testline', 'tag1 tag2 tag3')
-        assert.equal(line, testline)
-
-        line = log.debug('testline', 'tag1,tag2,tag3')
-        assert.equal(line, testline)
-
-        line = log.debug('testline', ['tag1', 'tag2', 'tag3'])
-        assert.equal(line, testline)
-      })
-    })
-  })
-  describe(': Name Set', function () {
-    beforeEach('create Object', function () {
-      log = new LOG({
-        name: name
-      })
-    })
-    afterEach('destroy Object', function () {
-      log = undefined
-    })
-    describe(': Info', function () {
-      it('should output the given Line', function () {
-        testline = getDate() + '\t' + hostname + '\t' + name + '\tINFO\ttestline'
-        line = log.info('testline')
-        assert.equal(line, testline)
-      })
-      it('should output the given Line with Tags', function () {
-        testline = getDate() + '\t' + hostname + '\t' + name + '\tINFO\ttestline #tag1 #tag2 #tag3'
-
-        line = log.info('testline', 'tag1 tag2 tag3')
-        assert.equal(line, testline)
-
-        line = log.info('testline', 'tag1,tag2,tag3')
-        assert.equal(line, testline)
-
-        line = log.info('testline', ['tag1', 'tag2', 'tag3'])
-        assert.equal(line, testline)
-      })
-    })
-    describe(': Notice', function () {
-      it('should output the given Line', function () {
-        testline = getDate() + '\t' + hostname + '\t' + name + '\tNOTICE\ttestline'
-        line = log.notice('testline')
-        assert.equal(line, testline)
-      })
-      it('should output the given Line with Tags', function () {
-        testline = getDate() + '\t' + hostname + '\t' + name + '\tNOTICE\ttestline #tag1 #tag2 #tag3'
-
-        line = log.notice('testline', 'tag1 tag2 tag3')
-        assert.equal(line, testline)
-
-        line = log.notice('testline', 'tag1,tag2,tag3')
-        assert.equal(line, testline)
-
-        line = log.notice('testline', ['tag1', 'tag2', 'tag3'])
-        assert.equal(line, testline)
-      })
-    })
-    describe(': Warn', function () {
-      it('should output the given Line', function () {
-        testline = getDate() + '\t' + hostname + '\t' + name + '\tWARN\ttestline'
-        line = log.warn('testline')
-        assert.equal(line, testline)
-      })
-      it('should output the given Line with Tags', function () {
-        testline = getDate() + '\t' + hostname + '\t' + name + '\tWARN\ttestline #tag1 #tag2 #tag3'
-
-        line = log.warn('testline', 'tag1 tag2 tag3')
-        assert.equal(line, testline)
-
-        line = log.warn('testline', 'tag1,tag2,tag3')
-        assert.equal(line, testline)
-
-        line = log.warn('testline', ['tag1', 'tag2', 'tag3'])
-        assert.equal(line, testline)
-      })
-    })
-    describe(': Error', function () {
-      it('should output the given Line', function () {
-        testline = getDate() + '\t' + hostname + '\t' + name + '\tERROR\ttestline'
-        line = log.error('testline')
-        assert.equal(line, testline)
-      })
-      it('should output the given Line with Tags', function () {
-        testline = getDate() + '\t' + hostname + '\t' + name + '\tERROR\ttestline #tag1 #tag2 #tag3'
-
-        line = log.error('testline', 'tag1 tag2 tag3')
-        assert.equal(line, testline)
-
-        line = log.error('testline', 'tag1,tag2,tag3')
-        assert.equal(line, testline)
-
-        line = log.error('testline', ['tag1', 'tag2', 'tag3'])
-        assert.equal(line, testline)
-      })
-    })
-    describe(': Fatal', function () {
-      it('should output the given Line', function () {
-        testline = getDate() + '\t' + hostname + '\t' + name + '\tFATAL\ttestline'
-        line = log.fatal('testline')
-        assert.equal(line, testline)
-      })
-      it('should output the given Line with Tags', function () {
-        testline = getDate() + '\t' + hostname + '\t' + name + '\tFATAL\ttestline #tag1 #tag2 #tag3'
-
-        line = log.fatal('testline', 'tag1 tag2 tag3')
-        assert.equal(line, testline)
-
-        line = log.fatal('testline', 'tag1,tag2,tag3')
-        assert.equal(line, testline)
-
-        line = log.fatal('testline', ['tag1', 'tag2', 'tag3'])
-        assert.equal(line, testline)
-      })
-    })
-    describe(': Debug', function () {
-      it('should output the given Line', function () {
-        testline = getDate() + '\t' + hostname + '\t' + name + '\tDEBUG\ttestline'
-        line = log.debug('testline')
-        assert.equal(line, testline)
-      })
-      it('should output the given Line with Tags', function () {
-        testline = getDate() + '\t' + hostname + '\t' + name + '\tDEBUG\ttestline #tag1 #tag2 #tag3'
-
-        line = log.debug('testline', 'tag1 tag2 tag3')
-        assert.equal(line, testline)
-
-        line = log.debug('testline', 'tag1,tag2,tag3')
-        assert.equal(line, testline)
-
-        line = log.debug('testline', ['tag1', 'tag2', 'tag3'])
-        assert.equal(line, testline)
-      })
-    })
-  })
-  describe(': File Set', function () {
-    beforeEach('create Object', function () {
-      log = new LOG({
-        file: file
-      })
-      fs.writeFileSync(file, '') // Create File if not exists
-    })
-    afterEach('destroy Object', function () {
-      log = undefined
-      fs.truncateSync(file) // Clean Up, clear contents
-    })
-    describe(': Info', function () {
-      it('should output the given Line to the file', function (done) {
-        testline = getDate() + '\t' + hostname + '\tlog\tINFO\ttestline\n'
-        log.info('testline')
-        setTimeout(function () {
-          line = fs.readFileSync(file, 'utf-8')
-          assert.equal(line, testline)
-          done()
-        }, 10)
-      })
-    })
-    describe(': Notice', function () {
-      it('should output the given Line to the file', function (done) {
-        testline = getDate() + '\t' + hostname + '\tlog\tNOTICE\ttestline\n'
-        log.notice('testline')
-        setTimeout(function () {
-          line = fs.readFileSync(file, 'utf-8')
-          assert.equal(line, testline)
-          done()
-        }, 10)
-      })
-    })
-    describe(': Warn', function () {
-      it('should output the given Line to the file', function (done) {
-        testline = getDate() + '\t' + hostname + '\tlog\tWARN\ttestline\n'
-        log.warn('testline')
-        setTimeout(function () {
-          line = fs.readFileSync(file, 'utf-8')
-          assert.equal(line, testline)
-          done()
-        }, 10)
-      })
-    })
-    describe(': Error', function () {
-      it('should output the given Line to the file', function (done) {
-        testline = getDate() + '\t' + hostname + '\tlog\tERROR\ttestline\n'
-        log.error('testline')
-        setTimeout(function () {
-          line = fs.readFileSync(file, 'utf-8')
-          assert.equal(line, testline)
-          done()
-        }, 10)
-      })
-    })
-    describe(': Fatal', function () {
-      it('should output the given Line to the file', function (done) {
-        testline = getDate() + '\t' + hostname + '\tlog\tFATAL\ttestline\n'
-        log.fatal('testline')
-        setTimeout(function () {
-          line = fs.readFileSync(file, 'utf-8')
-          assert.equal(line, testline)
-          done()
-        }, 10)
-      })
-    })
-    describe(': Debug', function () {
-      it('should output the given Line to the file', function (done) {
-        testline = getDate() + '\t' + hostname + '\tlog\tDEBUG\ttestline\n'
-        log.debug('testline')
-        setTimeout(function () {
-          line = fs.readFileSync(file, 'utf-8')
-          assert.equal(line, testline)
-          done()
-        }, 10)
-      })
-    })
-  })
-})
+/* global it, describe, beforeEach, afterEach */
+const assert = require('assert')
+const os = require('os')
+const path = require('path')
+const fs = require('fs')
+const LOG = require(path.join(__dirname, '../index.js'))
+const hostname = os.hostname()
+function getDate () {
+  var tzoffset = (new Date()).getTimezoneOffset() * 60000 // offset in milliseconds
+  var localISOTime = (new Date(Date.now() - tzoffset)).toISOString().slice(0, -1)
+  return localISOTime.split('.')[0].trim()
+}
+const manualhostname = 'testhost'
+const name = 'testapp'
+const file = '/tmp/testfile'
+let log
+let line
+let testline
+describe('Log.js', function () {
+  describe(': No Options', function () {
+    beforeEach('create Object', function () {
+      log = new LOG()
+    })
+    afterEach('destroy Object', function () {
+      log = undefined
+    })
+    describe(': Info', function () {
+      it('should output the given Line', function () {
+        testline = getDate() + '\t' + hostname + '\tlog\tINFO\ttestline'
+        line = log.info('testline')
+        assert.equal(line, testline)
+      })
+      it('should output the given Line with Tags', function () {
+        testline = getDate() + '\t' + hostname + '\tlog\tINFO\ttestline #tag1 #tag2 #tag3'
+
+        line = log.info('testline', 'tag1 tag2 tag3')
+        assert.equal(line, testline)
+
+        line = log.info('testline', 'tag1,tag2,tag3')
+        assert.equal(line, testline)
+
+        line = log.info('testline', ['tag1', 'tag2', 'tag3'])
+        assert.equal(line, testline)
+      })
+    })
+    describe(': Notice', function () {
+      it('should output the given Line', function () {
+        testline = getDate() + '\t' + hostname + '\tlog\tNOTICE\ttestline'
+        line = log.notice('testline')
+        assert.equal(line, testline)
+      })
+      it('should output the given Line with Tags', function () {
+        testline = getDate() + '\t' + hostname + '\tlog\tNOTICE\ttestline #tag1 #tag2 #tag3'
+
+        line = log.notice('testline', 'tag1 tag2 tag3')
+        assert.equal(line, testline)
+
+        line = log.notice('testline', 'tag1,tag2,tag3')
+        assert.equal(line, testline)
+
+        line = log.notice('testline', ['tag1', 'tag2', 'tag3'])
+        assert.equal(line, testline)
+      })
+    })
+    describe(': Warn', function () {
+      it('should output the given Line', function () {
+        testline = getDate() + '\t' + hostname + '\tlog\tWARN\ttestline'
+        line = log.warn('testline')
+        assert.equal(line, testline)
+      })
+      it('should output the given Line with Tags', function () {
+        testline = getDate() + '\t' + hostname + '\tlog\tWARN\ttestline #tag1 #tag2 #tag3'
+
+        line = log.warn('testline', 'tag1 tag2 tag3')
+        assert.equal(line, testline)
+
+        line = log.warn('testline', 'tag1,tag2,tag3')
+        assert.equal(line, testline)
+
+        line = log.warn('testline', ['tag1', 'tag2', 'tag3'])
+        assert.equal(line, testline)
+      })
+    })
+    describe(': Error', function () {
+      it('should output the given Line', function () {
+        testline = getDate() + '\t' + hostname + '\tlog\tERROR\ttestline'
+        line = log.error('testline')
+        assert.equal(line, testline)
+      })
+      it('should output the given Line with Tags', function () {
+        testline = getDate() + '\t' + hostname + '\tlog\tERROR\ttestline #tag1 #tag2 #tag3'
+
+        line = log.error('testline', 'tag1 tag2 tag3')
+        assert.equal(line, testline)
+
+        line = log.error('testline', 'tag1,tag2,tag3')
+        assert.equal(line, testline)
+
+        line = log.error('testline', ['tag1', 'tag2', 'tag3'])
+        assert.equal(line, testline)
+      })
+    })
+    describe(': Fatal', function () {
+      it('should output the given Line', function () {
+        testline = getDate() + '\t' + hostname + '\tlog\tFATAL\ttestline'
+        line = log.fatal('testline')
+        assert.equal(line, testline)
+      })
+      it('should output the given Line with Tags', function () {
+        testline = getDate() + '\t' + hostname + '\tlog\tFATAL\ttestline #tag1 #tag2 #tag3'
+
+        line = log.fatal('testline', 'tag1 tag2 tag3')
+        assert.equal(line, testline)
+
+        line = log.fatal('testline', 'tag1,tag2,tag3')
+        assert.equal(line, testline)
+
+        line = log.fatal('testline', ['tag1', 'tag2', 'tag3'])
+        assert.equal(line, testline)
+      })
+    })
+    describe(': Debug', function () {
+      it('should output the given Line', function () {
+        testline = getDate() + '\t' + hostname + '\tlog\tDEBUG\ttestline'
+        line = log.debug('testline')
+        assert.equal(line, testline)
+      })
+      it('should output the given Line with Tags', function () {
+        testline = getDate() + '\t' + hostname + '\tlog\tDEBUG\ttestline #tag1 #tag2 #tag3'
+
+        line = log.debug('testline', 'tag1 tag2 tag3')
+        assert.equal(line, testline)
+
+        line = log.debug('testline', 'tag1,tag2,tag3')
+        assert.equal(line, testline)
+
+        line = log.debug('testline', ['tag1', 'tag2', 'tag3'])
+        assert.equal(line, testline)
+      })
+    })
+  })
+  describe(': Hostname Set', function () {
+    beforeEach('create Object', function () {
+      log = new LOG({
+        hostname: manualhostname
+      })
+    })
+    afterEach('destroy Object', function () {
+      log = undefined
+    })
+    describe(': Info', function () {
+      it('should output the given Line', function () {
+        testline = getDate() + '\t' + manualhostname + '\tlog\tINFO\ttestline'
+        line = log.info('testline')
+        assert.equal(line, testline)
+      })
+      it('should output the given Line with Tags', function () {
+        testline = getDate() + '\t' + manualhostname + '\tlog\tINFO\ttestline #tag1 #tag2 #tag3'
+
+        line = log.info('testline', 'tag1 tag2 tag3')
+        assert.equal(line, testline)
+
+        line = log.info('testline', 'tag1,tag2,tag3')
+        assert.equal(line, testline)
+
+        line = log.info('testline', ['tag1', 'tag2', 'tag3'])
+        assert.equal(line, testline)
+      })
+    })
+    describe(': Notice', function () {
+      it('should output the given Line', function () {
+        testline = getDate() + '\t' + manualhostname + '\tlog\tNOTICE\ttestline'
+        line = log.notice('testline')
+        assert.equal(line, testline)
+      })
+      it('should output the given Line with Tags', function () {
+        testline = getDate() + '\t' + manualhostname + '\tlog\tNOTICE\ttestline #tag1 #tag2 #tag3'
+
+        line = log.notice('testline', 'tag1 tag2 tag3')
+        assert.equal(line, testline)
+
+        line = log.notice('testline', 'tag1,tag2,tag3')
+        assert.equal(line, testline)
+
+        line = log.notice('testline', ['tag1', 'tag2', 'tag3'])
+        assert.equal(line, testline)
+      })
+    })
+    describe(': Warn', function () {
+      it('should output the given Line', function () {
+        testline = getDate() + '\t' + manualhostname + '\tlog\tWARN\ttestline'
+        line = log.warn('testline')
+        assert.equal(line, testline)
+      })
+      it('should output the given Line with Tags', function () {
+        testline = getDate() + '\t' + manualhostname + '\tlog\tWARN\ttestline #tag1 #tag2 #tag3'
+
+        line = log.warn('testline', 'tag1 tag2 tag3')
+        assert.equal(line, testline)
+
+        line = log.warn('testline', 'tag1,tag2,tag3')
+        assert.equal(line, testline)
+
+        line = log.warn('testline', ['tag1', 'tag2', 'tag3'])
+        assert.equal(line, testline)
+      })
+    })
+    describe(': Error', function () {
+      it('should output the given Line', function () {
+        testline = getDate() + '\t' + manualhostname + '\tlog\tERROR\ttestline'
+        line = log.error('testline')
+        assert.equal(line, testline)
+      })
+      it('should output the given Line with Tags', function () {
+        testline = getDate() + '\t' + manualhostname + '\tlog\tERROR\ttestline #tag1 #tag2 #tag3'
+
+        line = log.error('testline', 'tag1 tag2 tag3')
+        assert.equal(line, testline)
+
+        line = log.error('testline', 'tag1,tag2,tag3')
+        assert.equal(line, testline)
+
+        line = log.error('testline', ['tag1', 'tag2', 'tag3'])
+        assert.equal(line, testline)
+      })
+    })
+    describe(': Fatal', function () {
+      it('should output the given Line', function () {
+        testline = getDate() + '\t' + manualhostname + '\tlog\tFATAL\ttestline'
+        line = log.fatal('testline')
+        assert.equal(line, testline)
+      })
+      it('should output the given Line with Tags', function () {
+        testline = getDate() + '\t' + manualhostname + '\tlog\tFATAL\ttestline #tag1 #tag2 #tag3'
+
+        line = log.fatal('testline', 'tag1 tag2 tag3')
+        assert.equal(line, testline)
+
+        line = log.fatal('testline', 'tag1,tag2,tag3')
+        assert.equal(line, testline)
+
+        line = log.fatal('testline', ['tag1', 'tag2', 'tag3'])
+        assert.equal(line, testline)
+      })
+    })
+    describe(': Debug', function () {
+      it('should output the given Line', function () {
+        testline = getDate() + '\t' + manualhostname + '\tlog\tDEBUG\ttestline'
+        line = log.debug('testline')
+        assert.equal(line, testline)
+      })
+      it('should output the given Line with Tags', function () {
+        testline = getDate() + '\t' + manualhostname + '\tlog\tDEBUG\ttestline #tag1 #tag2 #tag3'
+
+        line = log.debug('testline', 'tag1 tag2 tag3')
+        assert.equal(line, testline)
+
+        line = log.debug('testline', 'tag1,tag2,tag3')
+        assert.equal(line, testline)
+
+        line = log.debug('testline', ['tag1', 'tag2', 'tag3'])
+        assert.equal(line, testline)
+      })
+    })
+  })
+  describe(': Name Set', function () {
+    beforeEach('create Object', function () {
+      log = new LOG({
+        name: name
+      })
+    })
+    afterEach('destroy Object', function () {
+      log = undefined
+    })
+    describe(': Info', function () {
+      it('should output the given Line', function () {
+        testline = getDate() + '\t' + hostname + '\t' + name + '\tINFO\ttestline'
+        line = log.info('testline')
+        assert.equal(line, testline)
+      })
+      it('should output the given Line with Tags', function () {
+        testline = getDate() + '\t' + hostname + '\t' + name + '\tINFO\ttestline #tag1 #tag2 #tag3'
+
+        line = log.info('testline', 'tag1 tag2 tag3')
+        assert.equal(line, testline)
+
+        line = log.info('testline', 'tag1,tag2,tag3')
+        assert.equal(line, testline)
+
+        line = log.info('testline', ['tag1', 'tag2', 'tag3'])
+        assert.equal(line, testline)
+      })
+    })
+    describe(': Notice', function () {
+      it('should output the given Line', function () {
+        testline = getDate() + '\t' + hostname + '\t' + name + '\tNOTICE\ttestline'
+        line = log.notice('testline')
+        assert.equal(line, testline)
+      })
+      it('should output the given Line with Tags', function () {
+        testline = getDate() + '\t' + hostname + '\t' + name + '\tNOTICE\ttestline #tag1 #tag2 #tag3'
+
+        line = log.notice('testline', 'tag1 tag2 tag3')
+        assert.equal(line, testline)
+
+        line = log.notice('testline', 'tag1,tag2,tag3')
+        assert.equal(line, testline)
+
+        line = log.notice('testline', ['tag1', 'tag2', 'tag3'])
+        assert.equal(line, testline)
+      })
+    })
+    describe(': Warn', function () {
+      it('should output the given Line', function () {
+        testline = getDate() + '\t' + hostname + '\t' + name + '\tWARN\ttestline'
+        line = log.warn('testline')
+        assert.equal(line, testline)
+      })
+      it('should output the given Line with Tags', function () {
+        testline = getDate() + '\t' + hostname + '\t' + name + '\tWARN\ttestline #tag1 #tag2 #tag3'
+
+        line = log.warn('testline', 'tag1 tag2 tag3')
+        assert.equal(line, testline)
+
+        line = log.warn('testline', 'tag1,tag2,tag3')
+        assert.equal(line, testline)
+
+        line = log.warn('testline', ['tag1', 'tag2', 'tag3'])
+        assert.equal(line, testline)
+      })
+    })
+    describe(': Error', function () {
+      it('should output the given Line', function () {
+        testline = getDate() + '\t' + hostname + '\t' + name + '\tERROR\ttestline'
+        line = log.error('testline')
+        assert.equal(line, testline)
+      })
+      it('should output the given Line with Tags', function () {
+        testline = getDate() + '\t' + hostname + '\t' + name + '\tERROR\ttestline #tag1 #tag2 #tag3'
+
+        line = log.error('testline', 'tag1 tag2 tag3')
+        assert.equal(line, testline)
+
+        line = log.error('testline', 'tag1,tag2,tag3')
+        assert.equal(line, testline)
+
+        line = log.error('testline', ['tag1', 'tag2', 'tag3'])
+        assert.equal(line, testline)
+      })
+    })
+    describe(': Fatal', function () {
+      it('should output the given Line', function () {
+        testline = getDate() + '\t' + hostname + '\t' + name + '\tFATAL\ttestline'
+        line = log.fatal('testline')
+        assert.equal(line, testline)
+      })
+      it('should output the given Line with Tags', function () {
+        testline = getDate() + '\t' + hostname + '\t' + name + '\tFATAL\ttestline #tag1 #tag2 #tag3'
+
+        line = log.fatal('testline', 'tag1 tag2 tag3')
+        assert.equal(line, testline)
+
+        line = log.fatal('testline', 'tag1,tag2,tag3')
+        assert.equal(line, testline)
+
+        line = log.fatal('testline', ['tag1', 'tag2', 'tag3'])
+        assert.equal(line, testline)
+      })
+    })
+    describe(': Debug', function () {
+      it('should output the given Line', function () {
+        testline = getDate() + '\t' + hostname + '\t' + name + '\tDEBUG\ttestline'
+        line = log.debug('testline')
+        assert.equal(line, testline)
+      })
+      it('should output the given Line with Tags', function () {
+        testline = getDate() + '\t' + hostname + '\t' + name + '\tDEBUG\ttestline #tag1 #tag2 #tag3'
+
+        line = log.debug('testline', 'tag1 tag2 tag3')
+        assert.equal(line, testline)
+
+        line = log.debug('testline', 'tag1,tag2,tag3')
+        assert.equal(line, testline)
+
+        line = log.debug('testline', ['tag1', 'tag2', 'tag3'])
+        assert.equal(line, testline)
+      })
+    })
+  })
+  describe(': File Set', function () {
+    beforeEach('create Object', function () {
+      log = new LOG({
+        file: file
+      })
+      fs.writeFileSync(file, '') // Create File if not exists
+    })
+    afterEach('destroy Object', function () {
+      log = undefined
+      fs.truncateSync(file) // Clean Up, clear contents
+    })
+    describe(': Info', function () {
+      it('should output the given Line to the file', function (done) {
+        testline = getDate() + '\t' + hostname + '\tlog\tINFO\ttestline\n'
+        log.info('testline')
+        setTimeout(function () {
+          line = fs.readFileSync(file, 'utf-8')
+          assert.equal(line, testline)
+          done()
+        }, 10)
+      })
+    })
+    describe(': Notice', function () {
+      it('should output the given Line to the file', function (done) {
+        testline = getDate() + '\t' + hostname + '\tlog\tNOTICE\ttestline\n'
+        log.notice('testline')
+        setTimeout(function () {
+          line = fs.readFileSync(file, 'utf-8')
+          assert.equal(line, testline)
+          done()
+        }, 10)
+      })
+    })
+    describe(': Warn', function () {
+      it('should output the given Line to the file', function (done) {
+        testline = getDate() + '\t' + hostname + '\tlog\tWARN\ttestline\n'
+        log.warn('testline')
+        setTimeout(function () {
+          line = fs.readFileSync(file, 'utf-8')
+          assert.equal(line, testline)
+          done()
+        }, 10)
+      })
+    })
+    describe(': Error', function () {
+      it('should output the given Line to the file', function (done) {
+        testline = getDate() + '\t' + hostname + '\tlog\tERROR\ttestline\n'
+        log.error('testline')
+        setTimeout(function () {
+          line = fs.readFileSync(file, 'utf-8')
+          assert.equal(line, testline)
+          done()
+        }, 10)
+      })
+    })
+    describe(': Fatal', function () {
+      it('should output the given Line to the file', function (done) {
+        testline = getDate() + '\t' + hostname + '\tlog\tFATAL\ttestline\n'
+        log.fatal('testline')
+        setTimeout(function () {
+          line = fs.readFileSync(file, 'utf-8')
+          assert.equal(line, testline)
+          done()
+        }, 10)
+      })
+    })
+    describe(': Debug', function () {
+      it('should output the given Line to the file', function (done) {
+        testline = getDate() + '\t' + hostname + '\tlog\tDEBUG\ttestline\n'
+        log.debug('testline')
+        setTimeout(function () {
+          line = fs.readFileSync(file, 'utf-8')
+          assert.equal(line, testline)
+          done()
+        }, 10)
+      })
+    })
+  })
+})
-- 
GitLab