Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Logging: Add Logger-Options to constructor #19

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ Options:
verbose: 1, //Verbosity, default 0
oem: 0, //OEM Code from artisticlicense, default to dmxnet OEM.
sName: "Text", // 17 char long node description, default to "dmxnet"
lName: "Long description" // 63 char long node description, default to "dmxnet - OpenSource ArtNet Transceiver"
lName: "Long description", // 63 char long node description, default to "dmxnet - OpenSource ArtNet Transceiver"
log: {name: 'dmxnet', files: false} // Logging Options, see https://www.npmjs.com/package/@hibas123/nodelogging#setup
}
```

Expand Down
4 changes: 4 additions & 0 deletions example_tx.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ var dmxlib = require('./lib.js');
// Create new dmxnet instance
var dmxnet = new dmxlib.dmxnet({
verbose: 1,
log: {
files: false,
name: "dmxnet"
}
});
// Create new Sender instance
var sender = dmxnet.newSender({
Expand Down
7 changes: 4 additions & 3 deletions lib.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@ const Netmask = require('netmask').Netmask;
// Require Logging
const LoggingBase = require('@hibas123/nodelogging').LoggingBase;
// Init Logger
const log = new LoggingBase({
name: 'dmxnet',
});
let log;

// ArtDMX Header for jspack
var ArtDmxHeaderFormat = '!7sBHHBBBBH';
Expand All @@ -32,6 +30,7 @@ class dmxnet {
this.sName = options.sName || 'dmxnet'; // Shortname
this.lName = options.lName ||
'dmxnet - OpenSource ArtNet Transceiver'; // Longname
this.logOptions = options.log || {name: 'dmxnet'};
// Set log levels
if (this.verbose > 0) {
// ToDo: Set Log Level
Expand All @@ -41,6 +40,8 @@ class dmxnet {
} else {
// ToDo: Set Log Level
}
// Create Logger
log = new LoggingBase(this.logOptions);
// Log started information
log.log('started with options ' + JSON.stringify(options));

Expand Down