fable 3.0.31 → 3.0.32
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/README.md +33 -63
- package/debug/Harness.js +16 -2
- package/dist/fable.compatible.js +312 -271
- package/dist/fable.compatible.min.js +21 -21
- package/dist/fable.compatible.min.js.map +1 -1
- package/dist/fable.js +278 -237
- package/dist/fable.min.js +20 -20
- package/dist/fable.min.js.map +1 -1
- package/package.json +1 -1
- package/source/Fable.js +2 -2
- package/source/services/Fable-Service-DataFormat.js +638 -0
- package/source/services/Fable-Service-RestClient.js +81 -3
- package/source/services/Fable-Service-Utility.js +70 -0
- package/test/DataFormat-StringDateFormatting_tests.js +109 -0
- package/test/{FableDataArithmatic_tests.js → DataFormat-StringManipulation_tests.js} +88 -46
- package/test/DataFormat-StringNumberFormatting_tests.js +110 -0
- package/test/DataFormat-StringTokenization_tests.js +167 -0
- package/test/RestClient_test.js +54 -0
- package/test/{FableUtility_tests.js → Utility_tests.js} +13 -0
- /package/test/{FableOperations_tests.js → FableOperation_tests.js} +0 -0
- /package/test/{FableMetaTemplating_tests.js → MetaTemplating_tests.js} +0 -0
package/README.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
Fable Overview
|
|
2
2
|
=====
|
|
3
3
|
|
|
4
|
-
It is tiring to setup logging and settings management in every application you write. Fable provides a single line solution to have simple logging to the console
|
|
4
|
+
It is tiring to setup logging and settings management in every application you write. Fable provides a single line solution to have simple logging to the console and file, with the options for plugins to things like bunyan and graylog. Add a simple configuration object and it can also write the log to a file. Or even mongodb!
|
|
5
5
|
|
|
6
6
|
## Install
|
|
7
7
|
|
|
@@ -14,88 +14,62 @@ $ npm install fable
|
|
|
14
14
|
You can have basic low-level application services in a single line of code.
|
|
15
15
|
|
|
16
16
|
```js
|
|
17
|
-
|
|
17
|
+
const libFable = require('fable');
|
|
18
18
|
|
|
19
|
-
fable
|
|
19
|
+
var fable = new libFable();
|
|
20
|
+
|
|
21
|
+
fable.log.info('What are you doing, Dave?', {SomeColorSetting: 'Red', CurrentFolder: __dirname });
|
|
20
22
|
```
|
|
21
23
|
|
|
22
24
|
Which will output the following to the terminal:
|
|
23
25
|
```
|
|
24
26
|
$ node index.js
|
|
25
|
-
|
|
27
|
+
2023-05-09T23:04:34.041Z [info] (ApplicationNameHere): What are you doing, Dave?
|
|
28
|
+
{
|
|
29
|
+
"SomeColorSetting": "Red",
|
|
30
|
+
"CurrentFolder": "/Users/steven/Code/retold/modules/fable/fable/debug"
|
|
31
|
+
}
|
|
26
32
|
```
|
|
27
33
|
|
|
28
|
-
From this example, you can learn the following:
|
|
29
|
-
|
|
30
|
-
* It is pretty simple to start using the library
|
|
31
|
-
* The logging output looks really wierd on a standard terminal.
|
|
32
|
-
|
|
33
34
|
## Logging
|
|
34
35
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
To make the console log messages prettier, you can install the global bunyan library:
|
|
36
|
+
If you want logging to go to a file, you can do that too. Just configure the `LogStreams` array in the settings object like so (everything but the `loggertype` and `path` are optional):
|
|
38
37
|
|
|
39
|
-
```
|
|
40
|
-
nim install -g bunyan
|
|
41
|
-
```
|
|
42
|
-
|
|
43
|
-
After which you can send logging output through bunyan, turning this from the quickstart above:
|
|
44
|
-
|
|
45
|
-
```
|
|
46
|
-
$ node index.js
|
|
47
|
-
{"name":"Fable","hostname":"MathBookAir","pid":38807,"level":30,"Source":"0x53e0793606800000","ver":"0.0.0","datum":{"SomeColor":"Red","CurrentFolder":"/Users/steven/FableDemo1"},"msg":"What are you doing, Dave?","time":"2015-08-31T03:55:02.555Z","v":0}
|
|
48
|
-
```
|
|
49
|
-
|
|
50
|
-
Into something more readable:
|
|
51
|
-
|
|
52
|
-
```
|
|
53
|
-
$ node index.js |bunyan
|
|
54
|
-
[2015-08-31T04:06:10.230Z] INFO: Fable/38992 on MathBookAir: What are you doing, Dave? (Source=0x53e07bc20d400000, ver=0.0.0)
|
|
55
|
-
datum: {
|
|
56
|
-
"SomeColor": "Red",
|
|
57
|
-
"CurrentFolder": "/Users/steven/FableDemo1"
|
|
58
|
-
}
|
|
59
|
-
```
|
|
60
|
-
|
|
61
|
-
If you want logging to go to a file, you can do that too. Just configure the `LogStreams` array in the settings object like so:
|
|
62
|
-
|
|
63
|
-
```
|
|
38
|
+
```js
|
|
64
39
|
{
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
"UUID":
|
|
69
|
-
{
|
|
70
|
-
"DataCenter": 0,
|
|
71
|
-
"Worker": 0
|
|
72
|
-
},
|
|
73
|
-
"LogStreams":
|
|
40
|
+
Product:'SimpleFlatFileTest',
|
|
41
|
+
LogStreams:
|
|
74
42
|
[
|
|
75
43
|
{
|
|
76
|
-
|
|
77
|
-
|
|
44
|
+
// The loggertype is what tells fable-log to write to files
|
|
45
|
+
loggertype:'simpleflatfile',
|
|
46
|
+
outputloglinestoconsole: false,
|
|
47
|
+
showtimestamps: true,
|
|
48
|
+
formattedtimestamps: true,
|
|
49
|
+
level:'trace',
|
|
50
|
+
// The path is where it writes the files
|
|
51
|
+
path: '/tmp/Fable-Log-Test.log'
|
|
78
52
|
}
|
|
79
53
|
]
|
|
80
54
|
}
|
|
81
55
|
```
|
|
82
56
|
|
|
83
|
-
As long as the
|
|
57
|
+
As long as the `/tmp` folder exists and is writable, fable will write to that log file.
|
|
58
|
+
|
|
59
|
+
### Log Streams are Plugins for Fable-Log
|
|
84
60
|
|
|
85
|
-
|
|
61
|
+
If you want to create your own adapter for log streams, it is easily extensible. You can write your own plugin for fable-log, and include it during initialization. (examples to come)
|
|
86
62
|
|
|
87
|
-
|
|
63
|
+
### Log Streams are Multiplexed
|
|
88
64
|
|
|
89
|
-
-
|
|
90
|
-
- text file
|
|
91
|
-
- mongodb
|
|
65
|
+
You can decide to use multiple log streams simultaneously. If fable-log doesn't recognize the stream type in the configuration it falls back to terminal. *note this means it can lead to multiple copies of the same log entry*. You broke it, you bought it.
|
|
92
66
|
|
|
93
|
-
Below is a JSON configuration example containing
|
|
67
|
+
Below is a JSON configuration example containing two log streams:
|
|
94
68
|
|
|
95
69
|
```
|
|
96
70
|
{
|
|
97
71
|
"Product": "MyApplicationNameHere",
|
|
98
|
-
"ProductVersion": "
|
|
72
|
+
"ProductVersion": "3.1.9",
|
|
99
73
|
|
|
100
74
|
"UUID":
|
|
101
75
|
{
|
|
@@ -106,22 +80,19 @@ Below is a JSON configuration example containing all of the three log stream typ
|
|
|
106
80
|
[
|
|
107
81
|
{
|
|
108
82
|
"level": "trace",
|
|
83
|
+
"loggertype":"simpleflatfile",
|
|
109
84
|
"path": "./Logs/Application.log"
|
|
110
85
|
},
|
|
111
86
|
{
|
|
112
87
|
"level": "trace",
|
|
113
88
|
"streamtype": "process.stdout"
|
|
114
|
-
},
|
|
115
|
-
{
|
|
116
|
-
"level": "info",
|
|
117
|
-
"streamtype": "mongodb"
|
|
118
89
|
}
|
|
119
90
|
]
|
|
120
91
|
}
|
|
121
92
|
```
|
|
122
93
|
|
|
123
94
|
|
|
124
|
-
### _Fable.log.info(message, rawObject)
|
|
95
|
+
### Log Levels _Fable.log.info(message, rawObject)
|
|
125
96
|
|
|
126
97
|
Writes a log message to the `info` log level. All [bunyan](https://github.com/trentm/node-bunyan) log levels are supported, as the log object here is just a reference to bunyan.
|
|
127
98
|
|
|
@@ -321,5 +292,4 @@ __Example__
|
|
|
321
292
|
var uuid = fable.getUUID();
|
|
322
293
|
|
|
323
294
|
// The uuid variable now contains a unique string.
|
|
324
|
-
```
|
|
325
|
-
|
|
295
|
+
```
|
package/debug/Harness.js
CHANGED
|
@@ -15,7 +15,7 @@ class SimpleService extends libFable.ServiceProviderBase
|
|
|
15
15
|
}
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
-
let testFable = new libFable({});
|
|
18
|
+
let testFable = new libFable({"Product": "FableDebugHarness"});
|
|
19
19
|
|
|
20
20
|
testFable.serviceManager.addServiceType('SimpleService', SimpleService);
|
|
21
21
|
|
|
@@ -28,4 +28,18 @@ testFable.serviceManager.services['SimpleService']['SimpleService-123'].doSometh
|
|
|
28
28
|
|
|
29
29
|
console.log(`Initialized Service ${testFable.serviceManager.services['SimpleService']['SimpleService-123'].serviceType} as UUID ${testFable.serviceManager.services['SimpleService']['SimpleService-123'].UUID} with hash ${testFable.serviceManager.services['SimpleService']['SimpleService-123'].Hash}`);
|
|
30
30
|
|
|
31
|
-
testFable.serviceManager.services['SimpleService']['SimpleService-123'].doSomething();
|
|
31
|
+
testFable.serviceManager.services['SimpleService']['SimpleService-123'].doSomething();
|
|
32
|
+
|
|
33
|
+
// Instantiate the RestClient Service Provider
|
|
34
|
+
let tmpRestClient = testFable.serviceManager.instantiateServiceProvider('RestClient', {TraceLog: true}, 'RestClient-99');
|
|
35
|
+
|
|
36
|
+
// Download the wiktionary entry for dog!
|
|
37
|
+
tmpRestClient.getJSON('https://en.wiktionary.org/w/api.php?action=parse&prop=wikitext&format=json&page=dog',
|
|
38
|
+
(pError, pResponse, pBody)=>
|
|
39
|
+
{
|
|
40
|
+
testFable.log.info('Response received!');
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
var fable = new libFable();
|
|
44
|
+
|
|
45
|
+
fable.log.info('What are you doing, Dave?', {SomeColorSetting: 'Red', CurrentFolder: __dirname });
|