log-queue 0.0.8 → 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 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
- // 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()
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 = "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,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
@@ -2,7 +2,7 @@
2
2
  "author": {
3
3
  "name": "Jim Manton"
4
4
  },
5
- "version": "0.0.8",
5
+ "version": "2.0.0",
6
6
  "bundleDependencies": [],
7
7
  "dependencies": {
8
8
  "@types/node": "^18.11.19",
package/test/app.js CHANGED
@@ -5,15 +5,15 @@ describe('app', function () {
5
5
 
6
6
  it('app.constructor should pass', function () {
7
7
  application = require('../app.js')
8
- assert(app = new application())
8
+ assert(app = new application({ parent: null }))
9
9
  })
10
10
 
11
11
  it('app.logMsg is a function', function () {
12
12
  assert(typeof app.logMsg == 'function')
13
13
  })
14
14
 
15
- it('app.getFileObject is a function', function () {
16
- assert(typeof app.getFileObject == 'function')
15
+ it('app.init is a function', function () {
16
+ assert(typeof app.init == 'function')
17
17
  })
18
18
  })
19
19
 
@@ -22,16 +22,4 @@ describe('require', function () {
22
22
  it('colors', function () {
23
23
  assert(require('colors'))
24
24
  })
25
-
26
- it('base_queue', function () {
27
- assert(require('../base_queue/app'))
28
- })
29
-
30
- it('fs', function () {
31
- assert(require('fs'))
32
- })
33
-
34
- it('valid-path', function () {
35
- assert(require('valid-path'))
36
- })
37
25
  })
package/test/package.js CHANGED
@@ -6,7 +6,7 @@ const packageMock = {
6
6
  "author": {
7
7
  "name": "Jim Manton"
8
8
  },
9
- "version": "2.0.4",
9
+ "version": "2.0.0",
10
10
  "bundleDependencies": [],
11
11
  "dependencies": {
12
12
  "@types/node": "^18.11.19",
@@ -15,38 +15,32 @@ const packageMock = {
15
15
  "diffler": "^2.0.4",
16
16
  "fs": "^0.0.1-security",
17
17
  "mocha": "^10.2.0",
18
- "queuejson": "^9.0.11",
19
- "typescript": "^4.9.5",
20
18
  "valid-path": "^2.1.0"
21
19
  },
22
20
  "scripts": {
23
21
  "start": "node app.ts",
24
22
  "test": "mocha",
25
23
  "ditched": "ditched -a",
26
- "test_files": "node ./tests/files",
27
- "test_all": "node ./tests/test_all"
24
+ "test_logs": "node ./tests/logs"
28
25
  },
29
26
  "keywords": [
30
- "queue",
31
- "processing",
27
+ "log",
28
+ "console",
32
29
  "appenders",
33
30
  "javascript",
34
- "synchronous",
35
- "objects",
36
- "promises",
37
31
  "mocha"
38
32
  ],
39
- "homepage": "https://github.com/jman717/file-obj-queue",
33
+ "homepage": "https://github.com/jman717/log",
40
34
  "repository": {
41
35
  "type": "git",
42
- "url": "git+https://github.com/jman717/file-obj-queue.git"
36
+ "url": "git+https://github.com/jman717/log.git"
43
37
  },
44
38
  "deprecated": false,
45
- "description": "Queue File Objects",
39
+ "description": "Logging to console with eventual log4js-tagline support.",
46
40
  "email": "jrman@risebroadband.net",
47
41
  "license": "MIT",
48
42
  "main": "app.js",
49
- "name": "file-obj-queue",
43
+ "name": "log-queue",
50
44
  "start": "node app.js"
51
45
  }
52
46
 
package/tests/logs.js CHANGED
@@ -1,7 +1,13 @@
1
1
  var llog = require("../app.js"),
2
- a = 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"})
5
+
3
6
 
4
7
  a.logMsg({ msg: "hello world".debug, type: "debug" })
5
8
  a.logMsg({ msg: "hello world".silly, type: "silly" })
6
- a.logMsg({ msg: "hello world".error, type: "error" })
9
+ a.logMsg({ msg: "hello world".error.italic.bold, type: "error" })
7
10
 
11
+ b.logMsg({ msg: "hello world another example".debug.italic.bold, type: "debug" })
12
+ b.logMsg({ msg: "hello world another example".silly.italic.bold, type: "silly" })
13
+ b.logMsg({ msg: "hello world another example".error.italic.bold, type: "error" })