Skip to content
Snippets Groups Projects
Commit 7a0026e2 authored by Sigmund, Dominik's avatar Sigmund, Dominik
Browse files

Merge branch 'master' into 'graylog'

# Conflicts:
#   README.md
#   package.json
parents 12629dd9 9a70d1db
Branches
Tags
1 merge request!1Update index.test.js, examples/all-options.js, examples/log-to-file.js,...
node_modules
samples/file.log
coverage/
mochawesome-report/
.nyc_output/
\ No newline at end of file
stryker.log
*.DS_Store
image: node:latest
include:
- project: 'general/templates'
file: '/cicd/SAST-nodejs.gitlab-ci.yml'
- project: 'general/templates'
file: '/cicd/npm-audit.gitlab-ci.yml'
- project: 'general/templates'
file: '/cicd/sonarqube.gitlab-ci.yml'
variables:
SONAR_PROJECT_KEY: argos-log
SONAR_TOKEN: 11922a8e774494f51e1d2f0e695949e4073e7df8
cache:
paths:
......@@ -14,6 +20,7 @@ cache:
stages:
- build
- test
- quality
build:
stage: build
......@@ -29,6 +36,4 @@ test:
artifacts:
paths:
- docs/test-report.html
- docs/junit.xml
reports:
junit: docs/junit.xml
- docs/coverage/lcov.info
# log.js
# log
[![pipeline status](https://it-devops-01.br-edv.brnet.int/general/log/badges/master/pipeline.svg)](https://it-devops-01.br-edv.brnet.int/general/log/commits/master)
[![coverage report](https://it-devops-01.br-edv.brnet.int/general/log/badges/master/coverage.svg)](https://it-devops-01.br-edv.brnet.int/general/log/commits/master)
[![Quality Gate Status](https://it-devops-01.br-edv.brnet.int:8999/api/project_badges/measure?project=argos-log&metric=alert_status)](https://it-devops-01.br-edv.brnet.int:8999/dashboard?id=argos-log)
A real simple logger application.
May Optional Log to A File.
May Optional Log to A File and a graylog-server.
## Installation
`npm install --save git+ssh://git@it-devops-01.br-edv.brnet.int:argos/log.git`
- `npm config set @br:registry https://it-devops-01:4873`
- `npm install --save @br/config`
## Usage
`const Log = require('log')`
`const Log = require('@br/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 package-name will be used
......
File moved
File moved
File moved
declare module 'Log' {
const noTypesYet: any;
export default noTypesYet;
}
\ No newline at end of file
......@@ -3,7 +3,7 @@ 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 LOG = require('./index')
const hostname = os.hostname()
function getDate () {
var tzoffset = (new Date()).getTimezoneOffset() * 60000 // offset in milliseconds
......@@ -19,7 +19,7 @@ let orginialFile
let log
let line
let testline
describe('Log.js', () => {
describe('@br/Log', () => {
describe(': No Options', () => {
beforeEach(() => {
console.log('create Object')
......@@ -43,21 +43,21 @@ describe('Log.js', () => {
})
describe(': Warn', () => {
it('should output the given Line', () => {
testline = getDate() + '\t' + hostname + '\tlib-log\tWARN\ttestline'
testline = getDate() + '\t' + hostname + '\t@br/log\tWARN\ttestline'
line = log.warn('testline')
assert.equal(line, testline)
})
})
describe(': Error', () => {
it('should output the given Line', () => {
testline = getDate() + '\t' + hostname + '\tlib-log\tERROR\ttestline'
testline = getDate() + '\t' + hostname + '\t@br/log\tERROR\ttestline'
line = log.error('testline')
assert.equal(line, testline)
})
})
describe(': Fatal', () => {
it('should output the given Line', () => {
testline = getDate() + '\t' + hostname + '\tlib-log\tFATAL\ttestline'
testline = getDate() + '\t' + hostname + '\t@br/log\tFATAL\ttestline'
line = log.fatal('testline')
assert.equal(line, testline)
})
......@@ -94,21 +94,21 @@ describe('Log.js', () => {
})
describe(': Warn', () => {
it('should output the given Line', () => {
testline = getDate() + '\t' + manualhostname + '\tlib-log\tWARN\ttestline'
testline = getDate() + '\t' + manualhostname + '\t@br/log\tWARN\ttestline'
line = log.warn('testline')
assert.equal(line, testline)
})
})
describe(': Error', () => {
it('should output the given Line', () => {
testline = getDate() + '\t' + manualhostname + '\tlib-log\tERROR\ttestline'
testline = getDate() + '\t' + manualhostname + '\t@br/log\tERROR\ttestline'
line = log.error('testline')
assert.equal(line, testline)
})
})
describe(': Fatal', () => {
it('should output the given Line', () => {
testline = getDate() + '\t' + manualhostname + '\tlib-log\tFATAL\ttestline'
testline = getDate() + '\t' + manualhostname + '\t@br/log\tFATAL\ttestline'
line = log.fatal('testline')
assert.equal(line, testline)
})
......@@ -214,7 +214,7 @@ describe('Log.js', () => {
})
describe(': Warn', () => {
it('should output the given Line to the file', function (done) {
testline = getDate() + '\t' + hostname + '\tlib-log\tWARN\ttestline\n'
testline = getDate() + '\t' + hostname + '\t@br/log\tWARN\ttestline\n'
log.warn('testline')
setTimeout(() => {
line = fs.readFileSync(file, 'utf-8')
......@@ -225,7 +225,7 @@ describe('Log.js', () => {
})
describe(': Error', () => {
it('should output the given Line to the file', function (done) {
testline = getDate() + '\t' + hostname + '\tlib-log\tERROR\ttestline\n'
testline = getDate() + '\t' + hostname + '\t@br/log\tERROR\ttestline\n'
log.error('testline')
setTimeout(() => {
line = fs.readFileSync(file, 'utf-8')
......@@ -236,7 +236,7 @@ describe('Log.js', () => {
})
describe(': Fatal', () => {
it('should output the given Line to the file', function (done) {
testline = getDate() + '\t' + hostname + '\tlib-log\tFATAL\ttestline\n'
testline = getDate() + '\t' + hostname + '\t@br/log\tFATAL\ttestline\n'
log.fatal('testline')
setTimeout(() => {
line = fs.readFileSync(file, 'utf-8')
......@@ -269,42 +269,42 @@ describe('Log.js', () => {
})
describe(': Info', () => {
it('should output the given Line', () => {
testline = getDate() + '\t' + hostname + '\tlib-log\tINFO\ttestline'
testline = getDate() + '\t' + hostname + '\t@br/log\tINFO\ttestline'
line = log.info('testline')
assert.equal(line, testline)
})
})
describe(': Notice', () => {
it('should output the given Line', () => {
testline = getDate() + '\t' + hostname + '\tlib-log\tNOTICE\ttestline'
testline = getDate() + '\t' + hostname + '\t@br/log\tNOTICE\ttestline'
line = log.notice('testline')
assert.equal(line, testline)
})
})
describe(': Warn', () => {
it('should output the given Line', () => {
testline = getDate() + '\t' + hostname + '\tlib-log\tWARN\ttestline'
testline = getDate() + '\t' + hostname + '\t@br/log\tWARN\ttestline'
line = log.warn('testline')
assert.equal(line, testline)
})
})
describe(': Error', () => {
it('should output the given Line', () => {
testline = getDate() + '\t' + hostname + '\tlib-log\tERROR\ttestline'
testline = getDate() + '\t' + hostname + '\t@br/log\tERROR\ttestline'
line = log.error('testline')
assert.equal(line, testline)
})
})
describe(': Fatal', () => {
it('should output the given Line', () => {
testline = getDate() + '\t' + hostname + '\tlib-log\tFATAL\ttestline'
testline = getDate() + '\t' + hostname + '\t@br/log\tFATAL\ttestline'
line = log.fatal('testline')
assert.equal(line, testline)
})
})
describe(': Debug', () => {
it('should output the given Line', () => {
testline = getDate() + '\t' + hostname + '\tlib-log\tDEBUG\ttestline'
testline = getDate() + '\t' + hostname + '\t@br/log\tDEBUG\ttestline'
line = log.debug('testline')
assert.equal(line, testline)
})
......
{
"name": "lib-log",
"version": "2.1.0",
"name": "@br/log",
"version": "2.0.0",
"description": "A simple Logger with Options!",
"main": "index.js",
"scripts": {
"test": "jest tests/index.test.js"
"test": "jest",
"sonarqube": "sonar-scanner -Dsonar.projectKey=argos-log -Dsonar.sources=. -Dsonar.host.url=https://it-devops-01.br-edv.brnet.int:8999 -Dsonar.login=gitlab"
},
"author": "Dominik Sigmund <sigmund.dominik@googlemail.com> (https://webdad.eu)",
"license": "ISC",
"repository": {
"type": "git",
"url": "https://it-devops-01.br-edv.brnet.int/argos/log"
"url": "https://it-devops-01.br-edv.brnet.int/general/log"
},
"dependencies": {
"graylog2": "^0.2.1"
},
"devDependencies": {
"jest": "^24.9.0"
},
"jest": {
"collectCoverage": true,
"coverageReporters": [
"json",
"lcov",
"text",
"clover",
"html"
],
"coverageDirectory": "docs/coverage"
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment