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

Updated and refreshed #201

Open
wants to merge 10 commits 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
12 changes: 0 additions & 12 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,6 @@ commands:
paths:
- ~/.npm/_cacache
jobs:
node-v6:
docker:
- image: node:6
steps:
- test-nodejs
node-v8:
docker:
- image: node:8
steps:
- test-nodejs
node-v10:
docker:
- image: node:10
Expand All @@ -55,8 +45,6 @@ workflows:
version: 2
node-multi-build:
jobs:
- node-v6
- node-v8
- node-v10
- node-v12
- node-v14
17 changes: 16 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# forever-monitor [![Build Status](https://secure.travis-ci.org/foreverjs/forever-monitor.png)](http://travis-ci.org/foreverjs/forever-monitor)
# forever-monitor [![CircleCI](https://circleci.com/gh/lacrioque/forever-monitor/tree/master.svg?style=svg)](https://circleci.com/gh/lacrioque/forever-monitor/tree/master)

The core monitoring functionality of forever without the CLI

Expand Down Expand Up @@ -95,6 +95,21 @@ There are several options that you should be aware of when using forever. Most o
'outFile': 'path/to/file', // Path to log output from child stdout
'errFile': 'path/to/file', // Path to log output from child stderr

//
// Custom eventing options
//
"stdoutEventName" : "stdout" // This event will be fired on every child_process.on("stdout")
"stderrEventName" : "stderr" // This event will be fired on every child_process.on("stderr")


//
// Debug options to have a more refined debuggable logging
//
"debug": {
"prefix": "[DBG -%%-]" // %% will be replaced by the function (debug/log/warn/error)
"loglevel": 4 // 4 -> silent, 3 -> only error, 2-> error and warning 1-> error,warning,log, 0 -> everything
}

//
// ### function parseCommand (command, args)
// #### @command {String} Command string to parse
Expand Down
38 changes: 38 additions & 0 deletions lib/forever-monitor/debug.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
//
// Debug plugin for forever-monitor
//

module.exports = function (extOptions) {
const options = Object.assign({
loglevel: 4,
prefix: "[DBG -%%-]"
}, extOptions)

const debug = function () {
if (options.loglevel < 1) {
console.log(options.prefix.replace(/%%/, "DEBUG"), ...arguments);
}
}
const log = function () {
if (options.loglevel < 2) {
console.log(options.prefix.replace(/%%/, "LOG"), ...arguments);
}
}
const warn = function () {
if (options.loglevel < 3) {
console.warn(options.prefix.replace(/%%/, "WARN"), ...arguments);
}
}
const error = function () {
if (options.loglevel < 4) {
console.error(options.prefix.replace(/%%/, "ERROR"), ...arguments);
}
}

return {
debug,
log,
warn,
error
}
};
Loading