log-queue 1.0.0 → 2.0.1

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 CHANGED
@@ -25,50 +25,46 @@ exports = module.exports = class LogQueue {
25
25
  try {
26
26
 
27
27
  t.parent = props.parent
28
- t.relative_path = props.relative_path
29
28
  t.exclude_logMsg = props.exclude_logMsg
30
- t.resolve = props.resolve
31
- t.reject = props.reject
29
+ t.appender = "console"
30
+ t.logObj = null
32
31
 
33
32
  t.init = t.init.bind(t)
34
33
  t.logMsg = t.logMsg.bind(t)
35
- t.logMsg({ msg: `${fname}`.debug, type: 'debug' })
36
34
 
37
35
  return t
38
36
  } catch (e) {
39
37
  e.message = `${fname} error: ${e.message}`
38
+ console.log(e.message)
40
39
  throw (e)
41
40
  }
42
41
  }
43
42
 
44
- init(props) {
45
- var t = this, fname = `LogQueue.init`
43
+ init(props = {}) {
44
+ var t = this, fname = `LogQueue.init`, a, req
46
45
  try {
47
- // t.base_queue = new base_queue({
48
- // parent: t,
49
- // relative_path: t.relative_path,
50
- // logMsg: t.logMsg,
51
- // resolve: t.resolve,
52
- // reject: t.reject
53
- // }).load(props).process()
46
+ if (typeof props.appender != "undefined")
47
+ t.appender = props.appender
48
+ a = `./appenders/${t.appender}.js`
49
+ req = require(a)
50
+
51
+ t.logObj = new req({
52
+ parent: t,
53
+ exclude_logMsg: t.exclude_logMsg
54
+ })
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 = "log_queue.logMsg"
65
+ let t = this, fname = "LogQueue.logMsg"
63
66
  try {
64
- if (typeof props.msg == "undefined")
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,38 @@
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.exclude_logMsg = props.exclude_logMsg
12
+ t.logMsg = t.logMsg.bind(t)
13
+
14
+ return t
15
+ } catch (e) {
16
+ e.message = `${fname} error: ${e.message}`
17
+ throw (e)
18
+ }
19
+ }
20
+
21
+ logMsg(props = {}) {
22
+ let t = this, fname = "console.logMsg"
23
+ try {
24
+ if (typeof props.msg == "undefined")
25
+ throw new Error(`no msg property in (${JSON.stringify(props)}) `)
26
+ if (typeof props.type == "undefined")
27
+ throw new Error(`no type property in (${JSON.stringify(props)}) `)
28
+ if (typeof t.exclude_logMsg != "undefined")
29
+ if (t.exclude_logMsg.indexOf(props.type) > -1)
30
+ return
31
+ console.log(props.msg)
32
+ } catch (e) {
33
+ e.message = `${fname} error: ${e.message}`
34
+ console.log(e.message)
35
+ throw e
36
+ }
37
+ }
38
+ }
@@ -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
@@ -2,7 +2,7 @@
2
2
  "author": {
3
3
  "name": "Jim Manton"
4
4
  },
5
- "version": "1.0.0",
5
+ "version": "2.0.1",
6
6
  "bundleDependencies": [],
7
7
  "dependencies": {
8
8
  "@types/node": "^18.11.19",
package/test/package.js CHANGED
@@ -6,7 +6,7 @@ const packageMock = {
6
6
  "author": {
7
7
  "name": "Jim Manton"
8
8
  },
9
- "version": "1.0.0",
9
+ "version": "2.0.1",
10
10
  "bundleDependencies": [],
11
11
  "dependencies": {
12
12
  "@types/node": "^18.11.19",
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, exclude_logMsg: ["debug", "error"] })
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" })