log-queue 1.0.0 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/app.js +15 -19
- package/appenders/console.js +37 -0
- package/appenders/log4js-tagline.js +37 -0
- package/package.json +1 -1
- package/test/package.js +1 -1
- package/tests/logs.js +3 -2
package/app.js
CHANGED
|
@@ -29,46 +29,42 @@ exports = module.exports = class LogQueue {
|
|
|
29
29
|
t.exclude_logMsg = props.exclude_logMsg
|
|
30
30
|
t.resolve = props.resolve
|
|
31
31
|
t.reject = props.reject
|
|
32
|
+
t.appender = "console"
|
|
33
|
+
t.logObj = null
|
|
32
34
|
|
|
33
35
|
t.init = t.init.bind(t)
|
|
34
36
|
t.logMsg = t.logMsg.bind(t)
|
|
35
|
-
t.logMsg({ msg: `${fname}`.debug, type: 'debug' })
|
|
36
37
|
|
|
37
38
|
return t
|
|
38
39
|
} catch (e) {
|
|
39
40
|
e.message = `${fname} error: ${e.message}`
|
|
41
|
+
console.log(e.message)
|
|
40
42
|
throw (e)
|
|
41
43
|
}
|
|
42
44
|
}
|
|
43
45
|
|
|
44
|
-
init(props) {
|
|
45
|
-
var t = this, fname = `LogQueue.init
|
|
46
|
+
init(props = {}) {
|
|
47
|
+
var t = this, fname = `LogQueue.init`, a, req
|
|
46
48
|
try {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
49
|
+
if (typeof props.appender != "undefined")
|
|
50
|
+
t.appender = props.appender
|
|
51
|
+
a = `./appenders/${t.appender}.js`
|
|
52
|
+
req = require(a)
|
|
53
|
+
|
|
54
|
+
t.logObj = new req({parent: t})
|
|
55
|
+
|
|
54
56
|
return t
|
|
55
57
|
} catch (e) {
|
|
56
58
|
e.message = `${fname} error: ${e.message}`
|
|
59
|
+
console.log(e.message)
|
|
57
60
|
throw (e)
|
|
58
61
|
}
|
|
59
62
|
}
|
|
60
63
|
|
|
61
64
|
logMsg(props = {}) {
|
|
62
|
-
let t = this, fname = "
|
|
65
|
+
let t = this, fname = "LogQueue.logMsg"
|
|
63
66
|
try {
|
|
64
|
-
|
|
65
|
-
throw new Error(`no msg property in (${JSON.stringify(props)}) `)
|
|
66
|
-
if (typeof props.type == "undefined")
|
|
67
|
-
throw new Error(`no type property in (${JSON.stringify(props)}) `)
|
|
68
|
-
if (typeof t.exclude_logMsg != "undefined")
|
|
69
|
-
if (t.exclude_logMsg.indexOf(props.type) > -1)
|
|
70
|
-
return
|
|
71
|
-
console.log(props.msg)
|
|
67
|
+
t.logObj.logMsg(props)
|
|
72
68
|
} catch (e) {
|
|
73
69
|
e.message = `${fname} error: ${e.message}`
|
|
74
70
|
console.log(e.message)
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/* @author Jim Manton: jrman@risebroadband.net
|
|
2
|
+
* @since 2023-01-15
|
|
3
|
+
* console.js
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
exports = module.exports = class _console {
|
|
7
|
+
constructor(props) {
|
|
8
|
+
var t = this, fname = `console.constructor`
|
|
9
|
+
try {
|
|
10
|
+
t.parent = props.parent
|
|
11
|
+
t.logMsg = t.logMsg.bind(t)
|
|
12
|
+
|
|
13
|
+
return t
|
|
14
|
+
} catch (e) {
|
|
15
|
+
e.message = `${fname} error: ${e.message}`
|
|
16
|
+
throw (e)
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
logMsg(props = {}) {
|
|
21
|
+
let t = this, fname = "console.logMsg"
|
|
22
|
+
try {
|
|
23
|
+
if (typeof props.msg == "undefined")
|
|
24
|
+
throw new Error(`no msg property in (${JSON.stringify(props)}) `)
|
|
25
|
+
if (typeof props.type == "undefined")
|
|
26
|
+
throw new Error(`no type property in (${JSON.stringify(props)}) `)
|
|
27
|
+
if (typeof t.exclude_logMsg != "undefined")
|
|
28
|
+
if (t.exclude_logMsg.indexOf(props.type) > -1)
|
|
29
|
+
return
|
|
30
|
+
console.log(props.msg)
|
|
31
|
+
} catch (e) {
|
|
32
|
+
e.message = `${fname} error: ${e.message}`
|
|
33
|
+
console.log(e.message)
|
|
34
|
+
throw e
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/* @author Jim Manton: jrman@risebroadband.net
|
|
2
|
+
* @since 2023-01-15
|
|
3
|
+
* log4js_tagline.js
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
exports = module.exports = class log4js_tagline {
|
|
7
|
+
constructor(props) {
|
|
8
|
+
var t = this, fname = `log4js_tagline.constructor`
|
|
9
|
+
try {
|
|
10
|
+
t.parent = props.parent
|
|
11
|
+
t.logMsg = t.logMsg.bind(t)
|
|
12
|
+
|
|
13
|
+
return t
|
|
14
|
+
} catch (e) {
|
|
15
|
+
e.message = `${fname} error: ${e.message}`
|
|
16
|
+
throw (e)
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
logMsg(props = {}) {
|
|
21
|
+
let t = this, fname = "log4js_tagline.logMsg"
|
|
22
|
+
try {
|
|
23
|
+
if (typeof props.msg == "undefined")
|
|
24
|
+
throw new Error(`no msg property in (${JSON.stringify(props)}) `)
|
|
25
|
+
if (typeof props.type == "undefined")
|
|
26
|
+
throw new Error(`no type property in (${JSON.stringify(props)}) `)
|
|
27
|
+
if (typeof t.exclude_logMsg != "undefined")
|
|
28
|
+
if (t.exclude_logMsg.indexOf(props.type) > -1)
|
|
29
|
+
return
|
|
30
|
+
console.log(props.msg)
|
|
31
|
+
} catch (e) {
|
|
32
|
+
e.message = `${fname} error: ${e.message}`
|
|
33
|
+
console.log(e.message)
|
|
34
|
+
throw e
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
package/package.json
CHANGED
package/test/package.js
CHANGED
package/tests/logs.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
var llog = require("../app.js"),
|
|
2
|
-
a = new llog({ parent: null }),
|
|
3
|
-
b = new llog({ parent: null,
|
|
2
|
+
a = new llog({ parent: null }).init({appender: "console"}),
|
|
3
|
+
b = new llog({ parent: null,
|
|
4
|
+
exclude_logMsg: ["debug", "error"] }).init({appender: "console"})
|
|
4
5
|
|
|
5
6
|
|
|
6
7
|
a.logMsg({ msg: "hello world".debug, type: "debug" })
|