@esgi/syslog

0.1.0 • Public • Published

syslog

Syslog implementation for Node.js

Installation

$ npm install --save @esgi/syslog

Usage

'use strict'

const fs = require('fs')
const Syslog = require('@esgi/syslog').Syslog
const logFile = '/tmp/log/myapp/log.txt'
const charset = 'utf-8'
const host = 'https://myapp.com/'
const service = 'myapp'

const syslog = new Syslog(host, service)

fs.writeFileSync(logFile, syslog.Emergency('message'), charset)
fs.writeFileSync(logFile, syslog.Alert('message'), charset)
fs.writeFileSync(logFile, syslog.Critical('message', charset)
fs.writeFileSync(logFile, syslog.Error('message'), charset)
fs.writeFileSync(logFile, syslog.Warning('message'), charset)
fs.writeFileSync(logFile, syslog.Notice('message', charset)
fs.writeFileSync(logFile, syslog.Informational('message'), charset)
fs.writeFileSync(logFile, syslog.Debug('message'), charset)

Example Output

2019-02-02T17:00:38.343Z https://myapp.com/ myapp [debug] syslog debug test

Yarn Installation

- npm install --save @esgi/syslog
+ yarn add @esgi/syslog

CommonJS with ECMAScript 2015 Usage

- const fs = require('fs')
+ const {writeFileSync} = require('fs')

- const Syslog = require('@esgi/syslog').Syslog
+ const {Syslog} = require('@esgi/syslog')

- fs.writeFileSync(logFile, syslog.Emergency('message'), charset)
+ writeFileSync(logFile, syslog.Emergency('message'), charset)

- fs.writeFileSync(logFile, syslog.Alert('message'), charset)
+ writeFileSync(logFile, syslog.Alert('message'), charset)

- fs.writeFileSync(logFile, syslog.Critical('message', charset)
+ writeFileSync(logFile, syslog.Critical('message', charset)

- fs.writeFileSync(logFile, syslog.Error('message'), charset)
+ writeFileSync(logFile, syslog.Error('message'), charset)

- fs.writeFileSync(logFile, syslog.Warning('message'), charset)
+ writeFileSync(logFile, syslog.Warning('message'), charset)

- fs.writeFileSync(logFile, syslog.Notice('message', charset)
+ writeFileSync(logFile, syslog.Notice('message', charset)

- fs.writeFileSync(logFile, syslog.Informational('message'), charset)
+ writeFileSync(logFile, syslog.Informational('message'), charset)

- fs.writeFileSync(logFile, syslog.Debug('message'), charset)
+ writeFileSync(logFile, syslog.Debug('message'), charset)

ECMAScript Modules Usage

- const fs = require('fs')
+ import {writeFileSync} from 'fs'

- const Syslog = require('@esgi/syslog').Syslog
+ import {Syslog} from '@esgi/syslog'

- fs.writeFileSync(logFile, syslog.Emergency('message'), charset)
+ writeFileSync(logFile, syslog.Emergency('message'), charset)

- fs.writeFileSync(logFile, syslog.Alert('message'), charset)
+ writeFileSync(logFile, syslog.Alert('message'), charset)

- fs.writeFileSync(logFile, syslog.Critical('message', charset)
+ writeFileSync(logFile, syslog.Critical('message', charset)

- fs.writeFileSync(logFile, syslog.Error('message'), charset)
+ writeFileSync(logFile, syslog.Error('message'), charset)

- fs.writeFileSync(logFile, syslog.Warning('message'), charset)
+ writeFileSync(logFile, syslog.Warning('message'), charset)

- fs.writeFileSync(logFile, syslog.Notice('message', charset)
+ writeFileSync(logFile, syslog.Notice('message', charset)

- fs.writeFileSync(logFile, syslog.Informational('message'), charset)
+ writeFileSync(logFile, syslog.Informational('message'), charset)

- fs.writeFileSync(logFile, syslog.Debug('message'), charset)
+ writeFileSync(logFile, syslog.Debug('message'), charset)

Readme

Keywords

none

Package Sidebar

Install

npm i @esgi/syslog

Weekly Downloads

1

Version

0.1.0

License

MIT

Unpacked Size

16.3 kB

Total Files

7

Last publish

Collaborators

  • aminnairi