@niceties/draftlog-appender 1.0.5 → 1.2.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/dist/core.cjs +61 -47
- package/dist/core.mjs +61 -47
- package/dist/details/model.d.ts +7 -5
- package/dist/index.cjs +9 -4
- package/dist/index.mjs +9 -4
- package/package.json +21 -25
package/dist/core.cjs
CHANGED
|
@@ -3,14 +3,14 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
var draftlog = require('draftlog');
|
|
6
|
+
var list = require('@slimlib/list');
|
|
6
7
|
|
|
7
8
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
8
9
|
|
|
9
10
|
var draftlog__default = /*#__PURE__*/_interopDefaultLegacy(draftlog);
|
|
10
11
|
|
|
11
12
|
function createCanvas(spinner, formatter, ident) {
|
|
12
|
-
draftlog__default["default"](console)
|
|
13
|
-
.addLineListener(process.stdin);
|
|
13
|
+
draftlog__default["default"](console);
|
|
14
14
|
draftlog__default["default"].defaults.canReWrite = false;
|
|
15
15
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
16
16
|
const updaters = [];
|
|
@@ -19,33 +19,45 @@ function createCanvas(spinner, formatter, ident) {
|
|
|
19
19
|
updaters.splice(0, model.skipLines_);
|
|
20
20
|
model.skipLines_ = 0;
|
|
21
21
|
}
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
let key = 0;
|
|
26
|
-
const stack = [[...model.items_]];
|
|
27
|
-
while (stack.length) {
|
|
28
|
-
const item = stack[stack.length - 1].shift();
|
|
22
|
+
let key = 0, dirty = false;
|
|
23
|
+
const stack = [];
|
|
24
|
+
for (const item of model) {
|
|
29
25
|
let updater = updaters[Number(key)];
|
|
30
26
|
if (!updater) {
|
|
31
27
|
updater = console.draft(' ');
|
|
32
28
|
updaters.push(updater);
|
|
33
29
|
}
|
|
34
|
-
|
|
35
|
-
|
|
30
|
+
if (dirty || item.dirty_ || item.status_) {
|
|
31
|
+
const prefix = getPrefix(item.status_, model.tick_);
|
|
32
|
+
updater(formatter({
|
|
33
|
+
loglevel: item.loglevel_,
|
|
34
|
+
message: item.text_,
|
|
35
|
+
context: item.context_,
|
|
36
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
37
|
+
action: (item.status_ === undefined ? 3 /* log */ : undefined),
|
|
38
|
+
tag: item.tag_
|
|
39
|
+
}, prefix, ident * stack.length));
|
|
40
|
+
if (item.dirty_) {
|
|
41
|
+
item.dirty_ = false;
|
|
42
|
+
dirty = true;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
36
45
|
// iterate
|
|
37
46
|
++key;
|
|
38
|
-
if (
|
|
39
|
-
stack
|
|
47
|
+
if (stack[stack.length - 1] === item) {
|
|
48
|
+
stack[stack.length - 1] = null;
|
|
40
49
|
}
|
|
41
|
-
|
|
50
|
+
if (item.lastLeaf_) {
|
|
51
|
+
stack.push(item.lastLeaf_);
|
|
52
|
+
}
|
|
53
|
+
while (stack.length && stack[stack.length - 1] == null) {
|
|
42
54
|
stack.pop();
|
|
43
55
|
}
|
|
44
56
|
}
|
|
45
57
|
};
|
|
46
|
-
function
|
|
58
|
+
function getPrefix(status, tick) {
|
|
47
59
|
// status is truthy when it is inprogress
|
|
48
|
-
const prefix = status ?
|
|
60
|
+
const prefix = status ? spinner.frames[tick] :
|
|
49
61
|
// status not null when it is finished
|
|
50
62
|
status != null;
|
|
51
63
|
return prefix;
|
|
@@ -53,16 +65,12 @@ function createCanvas(spinner, formatter, ident) {
|
|
|
53
65
|
}
|
|
54
66
|
|
|
55
67
|
function createModel(logAboveSpinners) {
|
|
56
|
-
const model =
|
|
57
|
-
|
|
58
|
-
tick_: 0,
|
|
59
|
-
spinning_: 0,
|
|
60
|
-
items_: []
|
|
61
|
-
};
|
|
68
|
+
const model = new list.List();
|
|
69
|
+
model.tick_ = model.skipLines_ = model.spinning_ = 0;
|
|
62
70
|
const itemById = Object.create(null);
|
|
63
|
-
return [({ message: text, inputId, action, loglevel, ref, parentId }) => {
|
|
71
|
+
return [({ message: text, inputId, action, loglevel, ref, parentId, context, tag }) => {
|
|
64
72
|
// item has status undefined, so it is static by default
|
|
65
|
-
const item = { text_: text, loglevel_: loglevel, ref_: ref, parentId_: parentId,
|
|
73
|
+
const item = { text_: text, loglevel_: loglevel, ref_: ref, parentId_: parentId, dirty_: true, context_: context, tag_: tag };
|
|
66
74
|
if (action === 0 /* start */) {
|
|
67
75
|
item.status_ = 1 /* inprogress */;
|
|
68
76
|
}
|
|
@@ -70,20 +78,25 @@ function createModel(logAboveSpinners) {
|
|
|
70
78
|
item.status_ = 0 /* finished */;
|
|
71
79
|
}
|
|
72
80
|
if (action !== 3 /* log */) {
|
|
73
|
-
// if status still empty in the original item
|
|
81
|
+
// if status still empty in the original item or item does not exists it will remain empty and static
|
|
74
82
|
updateModel(inputId, item);
|
|
75
83
|
}
|
|
76
84
|
cleanupModel();
|
|
77
85
|
if (action === 3 /* log */) {
|
|
78
|
-
|
|
86
|
+
appendToModel(item, logAboveSpinners);
|
|
79
87
|
}
|
|
80
88
|
return model;
|
|
81
89
|
}, () => {
|
|
82
90
|
cleanupModel();
|
|
83
91
|
return model;
|
|
84
92
|
}];
|
|
85
|
-
function
|
|
86
|
-
|
|
93
|
+
function appendToModel(item, head) {
|
|
94
|
+
if (head) {
|
|
95
|
+
list.prepend(model, item);
|
|
96
|
+
}
|
|
97
|
+
else {
|
|
98
|
+
list.append(model, item);
|
|
99
|
+
}
|
|
87
100
|
model.spinning_ += (item.status_ || 0);
|
|
88
101
|
}
|
|
89
102
|
function updateModel(inputId, options) {
|
|
@@ -93,46 +106,47 @@ function createModel(logAboveSpinners) {
|
|
|
93
106
|
itemById[inputId] = item;
|
|
94
107
|
const itemParentId = item.parentId_;
|
|
95
108
|
if (itemParentId != null) {
|
|
96
|
-
putIntoChildren(itemParentId, item);
|
|
109
|
+
putIntoChildren(itemParentId, item, item);
|
|
97
110
|
}
|
|
98
111
|
else {
|
|
99
|
-
|
|
112
|
+
appendToModel(item, false);
|
|
100
113
|
}
|
|
101
114
|
}
|
|
102
115
|
else {
|
|
103
116
|
const statusDiff = (options.status_ || 0) - (modelItem.status_ || 0);
|
|
104
|
-
delete options.children_;
|
|
105
117
|
const moveIntoParent = options.parentId_ != null && modelItem.parentId_ == null;
|
|
106
118
|
Object.assign(modelItem, options);
|
|
107
119
|
model.spinning_ += statusDiff;
|
|
108
120
|
if (moveIntoParent) {
|
|
109
|
-
|
|
121
|
+
let lastLeaf = modelItem;
|
|
122
|
+
while (lastLeaf.lastLeaf_) {
|
|
123
|
+
lastLeaf = lastLeaf.lastLeaf_;
|
|
124
|
+
}
|
|
110
125
|
model.spinning_ -= (modelItem.status_ || 0);
|
|
111
|
-
|
|
126
|
+
modelItem.dirty_ = true;
|
|
127
|
+
list.removeRange(modelItem, lastLeaf);
|
|
128
|
+
putIntoChildren(modelItem.parentId_, modelItem, lastLeaf);
|
|
112
129
|
}
|
|
113
130
|
}
|
|
114
131
|
}
|
|
115
|
-
function putIntoChildren(itemParentId,
|
|
132
|
+
function putIntoChildren(itemParentId, begin, end) {
|
|
116
133
|
let parent = itemById[itemParentId];
|
|
117
134
|
if (!parent) {
|
|
118
|
-
parent = { inputId_: itemParentId, text_: '',
|
|
119
|
-
|
|
135
|
+
parent = { inputId_: itemParentId, text_: '', loglevel_: 0, ref_: new WeakRef(model) };
|
|
136
|
+
appendToModel(parent, false);
|
|
120
137
|
itemById[itemParentId] = parent;
|
|
121
138
|
}
|
|
122
|
-
parent.
|
|
123
|
-
|
|
139
|
+
list.appendRange((parent.lastLeaf_ || parent), begin, end);
|
|
140
|
+
parent.lastLeaf_ = begin;
|
|
141
|
+
model.spinning_ += (begin.status_ || 0);
|
|
124
142
|
}
|
|
125
143
|
function cleanupModel() {
|
|
126
144
|
var _a;
|
|
127
|
-
for (const item of model
|
|
128
|
-
if (!((_a = item.ref_) === null || _a === void 0 ? void 0 : _a.deref())
|
|
129
|
-
model.skipLines_ += 1
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
do {
|
|
133
|
-
currentItem.inputId_ != null && delete itemById[currentItem.inputId_];
|
|
134
|
-
model.spinning_ -= (currentItem.status_ || 0);
|
|
135
|
-
} while ((currentItem = item.children_.pop()));
|
|
145
|
+
for (const item of model) {
|
|
146
|
+
if (!((_a = item.ref_) === null || _a === void 0 ? void 0 : _a.deref())) {
|
|
147
|
+
model.skipLines_ += 1;
|
|
148
|
+
item.inputId_ != null && delete itemById[item.inputId_];
|
|
149
|
+
list.remove(item);
|
|
136
150
|
}
|
|
137
151
|
else {
|
|
138
152
|
break;
|
package/dist/core.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import draftlog from 'draftlog';
|
|
2
|
+
import { List, prepend, append, removeRange, appendRange, remove } from '@slimlib/list';
|
|
2
3
|
|
|
3
4
|
function createCanvas(spinner, formatter, ident) {
|
|
4
|
-
draftlog(console)
|
|
5
|
-
.addLineListener(process.stdin);
|
|
5
|
+
draftlog(console);
|
|
6
6
|
draftlog.defaults.canReWrite = false;
|
|
7
7
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
8
8
|
const updaters = [];
|
|
@@ -11,33 +11,45 @@ function createCanvas(spinner, formatter, ident) {
|
|
|
11
11
|
updaters.splice(0, model.skipLines_);
|
|
12
12
|
model.skipLines_ = 0;
|
|
13
13
|
}
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
let key = 0;
|
|
18
|
-
const stack = [[...model.items_]];
|
|
19
|
-
while (stack.length) {
|
|
20
|
-
const item = stack[stack.length - 1].shift();
|
|
14
|
+
let key = 0, dirty = false;
|
|
15
|
+
const stack = [];
|
|
16
|
+
for (const item of model) {
|
|
21
17
|
let updater = updaters[Number(key)];
|
|
22
18
|
if (!updater) {
|
|
23
19
|
updater = console.draft(' ');
|
|
24
20
|
updaters.push(updater);
|
|
25
21
|
}
|
|
26
|
-
|
|
27
|
-
|
|
22
|
+
if (dirty || item.dirty_ || item.status_) {
|
|
23
|
+
const prefix = getPrefix(item.status_, model.tick_);
|
|
24
|
+
updater(formatter({
|
|
25
|
+
loglevel: item.loglevel_,
|
|
26
|
+
message: item.text_,
|
|
27
|
+
context: item.context_,
|
|
28
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
29
|
+
action: (item.status_ === undefined ? 3 /* log */ : undefined),
|
|
30
|
+
tag: item.tag_
|
|
31
|
+
}, prefix, ident * stack.length));
|
|
32
|
+
if (item.dirty_) {
|
|
33
|
+
item.dirty_ = false;
|
|
34
|
+
dirty = true;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
28
37
|
// iterate
|
|
29
38
|
++key;
|
|
30
|
-
if (
|
|
31
|
-
stack
|
|
39
|
+
if (stack[stack.length - 1] === item) {
|
|
40
|
+
stack[stack.length - 1] = null;
|
|
32
41
|
}
|
|
33
|
-
|
|
42
|
+
if (item.lastLeaf_) {
|
|
43
|
+
stack.push(item.lastLeaf_);
|
|
44
|
+
}
|
|
45
|
+
while (stack.length && stack[stack.length - 1] == null) {
|
|
34
46
|
stack.pop();
|
|
35
47
|
}
|
|
36
48
|
}
|
|
37
49
|
};
|
|
38
|
-
function
|
|
50
|
+
function getPrefix(status, tick) {
|
|
39
51
|
// status is truthy when it is inprogress
|
|
40
|
-
const prefix = status ?
|
|
52
|
+
const prefix = status ? spinner.frames[tick] :
|
|
41
53
|
// status not null when it is finished
|
|
42
54
|
status != null;
|
|
43
55
|
return prefix;
|
|
@@ -45,16 +57,12 @@ function createCanvas(spinner, formatter, ident) {
|
|
|
45
57
|
}
|
|
46
58
|
|
|
47
59
|
function createModel(logAboveSpinners) {
|
|
48
|
-
const model =
|
|
49
|
-
|
|
50
|
-
tick_: 0,
|
|
51
|
-
spinning_: 0,
|
|
52
|
-
items_: []
|
|
53
|
-
};
|
|
60
|
+
const model = new List();
|
|
61
|
+
model.tick_ = model.skipLines_ = model.spinning_ = 0;
|
|
54
62
|
const itemById = Object.create(null);
|
|
55
|
-
return [({ message: text, inputId, action, loglevel, ref, parentId }) => {
|
|
63
|
+
return [({ message: text, inputId, action, loglevel, ref, parentId, context, tag }) => {
|
|
56
64
|
// item has status undefined, so it is static by default
|
|
57
|
-
const item = { text_: text, loglevel_: loglevel, ref_: ref, parentId_: parentId,
|
|
65
|
+
const item = { text_: text, loglevel_: loglevel, ref_: ref, parentId_: parentId, dirty_: true, context_: context, tag_: tag };
|
|
58
66
|
if (action === 0 /* start */) {
|
|
59
67
|
item.status_ = 1 /* inprogress */;
|
|
60
68
|
}
|
|
@@ -62,20 +70,25 @@ function createModel(logAboveSpinners) {
|
|
|
62
70
|
item.status_ = 0 /* finished */;
|
|
63
71
|
}
|
|
64
72
|
if (action !== 3 /* log */) {
|
|
65
|
-
// if status still empty in the original item
|
|
73
|
+
// if status still empty in the original item or item does not exists it will remain empty and static
|
|
66
74
|
updateModel(inputId, item);
|
|
67
75
|
}
|
|
68
76
|
cleanupModel();
|
|
69
77
|
if (action === 3 /* log */) {
|
|
70
|
-
|
|
78
|
+
appendToModel(item, logAboveSpinners);
|
|
71
79
|
}
|
|
72
80
|
return model;
|
|
73
81
|
}, () => {
|
|
74
82
|
cleanupModel();
|
|
75
83
|
return model;
|
|
76
84
|
}];
|
|
77
|
-
function
|
|
78
|
-
|
|
85
|
+
function appendToModel(item, head) {
|
|
86
|
+
if (head) {
|
|
87
|
+
prepend(model, item);
|
|
88
|
+
}
|
|
89
|
+
else {
|
|
90
|
+
append(model, item);
|
|
91
|
+
}
|
|
79
92
|
model.spinning_ += (item.status_ || 0);
|
|
80
93
|
}
|
|
81
94
|
function updateModel(inputId, options) {
|
|
@@ -85,46 +98,47 @@ function createModel(logAboveSpinners) {
|
|
|
85
98
|
itemById[inputId] = item;
|
|
86
99
|
const itemParentId = item.parentId_;
|
|
87
100
|
if (itemParentId != null) {
|
|
88
|
-
putIntoChildren(itemParentId, item);
|
|
101
|
+
putIntoChildren(itemParentId, item, item);
|
|
89
102
|
}
|
|
90
103
|
else {
|
|
91
|
-
|
|
104
|
+
appendToModel(item, false);
|
|
92
105
|
}
|
|
93
106
|
}
|
|
94
107
|
else {
|
|
95
108
|
const statusDiff = (options.status_ || 0) - (modelItem.status_ || 0);
|
|
96
|
-
delete options.children_;
|
|
97
109
|
const moveIntoParent = options.parentId_ != null && modelItem.parentId_ == null;
|
|
98
110
|
Object.assign(modelItem, options);
|
|
99
111
|
model.spinning_ += statusDiff;
|
|
100
112
|
if (moveIntoParent) {
|
|
101
|
-
|
|
113
|
+
let lastLeaf = modelItem;
|
|
114
|
+
while (lastLeaf.lastLeaf_) {
|
|
115
|
+
lastLeaf = lastLeaf.lastLeaf_;
|
|
116
|
+
}
|
|
102
117
|
model.spinning_ -= (modelItem.status_ || 0);
|
|
103
|
-
|
|
118
|
+
modelItem.dirty_ = true;
|
|
119
|
+
removeRange(modelItem, lastLeaf);
|
|
120
|
+
putIntoChildren(modelItem.parentId_, modelItem, lastLeaf);
|
|
104
121
|
}
|
|
105
122
|
}
|
|
106
123
|
}
|
|
107
|
-
function putIntoChildren(itemParentId,
|
|
124
|
+
function putIntoChildren(itemParentId, begin, end) {
|
|
108
125
|
let parent = itemById[itemParentId];
|
|
109
126
|
if (!parent) {
|
|
110
|
-
parent = { inputId_: itemParentId, text_: '',
|
|
111
|
-
|
|
127
|
+
parent = { inputId_: itemParentId, text_: '', loglevel_: 0, ref_: new WeakRef(model) };
|
|
128
|
+
appendToModel(parent, false);
|
|
112
129
|
itemById[itemParentId] = parent;
|
|
113
130
|
}
|
|
114
|
-
parent.
|
|
115
|
-
|
|
131
|
+
appendRange((parent.lastLeaf_ || parent), begin, end);
|
|
132
|
+
parent.lastLeaf_ = begin;
|
|
133
|
+
model.spinning_ += (begin.status_ || 0);
|
|
116
134
|
}
|
|
117
135
|
function cleanupModel() {
|
|
118
136
|
var _a;
|
|
119
|
-
for (const item of model
|
|
120
|
-
if (!((_a = item.ref_) === null || _a === void 0 ? void 0 : _a.deref())
|
|
121
|
-
model.skipLines_ += 1
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
do {
|
|
125
|
-
currentItem.inputId_ != null && delete itemById[currentItem.inputId_];
|
|
126
|
-
model.spinning_ -= (currentItem.status_ || 0);
|
|
127
|
-
} while ((currentItem = item.children_.pop()));
|
|
137
|
+
for (const item of model) {
|
|
138
|
+
if (!((_a = item.ref_) === null || _a === void 0 ? void 0 : _a.deref())) {
|
|
139
|
+
model.skipLines_ += 1;
|
|
140
|
+
item.inputId_ != null && delete itemById[item.inputId_];
|
|
141
|
+
remove(item);
|
|
128
142
|
}
|
|
129
143
|
else {
|
|
130
144
|
break;
|
package/dist/details/model.d.ts
CHANGED
|
@@ -1,20 +1,22 @@
|
|
|
1
1
|
import { LogLevel, LogMessage } from '@niceties/logger/types';
|
|
2
|
+
import { List, ListNode } from '@slimlib/list';
|
|
2
3
|
export declare const enum ItemStatus {
|
|
3
4
|
finished = 0,
|
|
4
5
|
inprogress = 1
|
|
5
6
|
}
|
|
6
|
-
export interface ModelItem {
|
|
7
|
+
export interface ModelItem extends Partial<ListNode> {
|
|
7
8
|
inputId_?: number;
|
|
8
9
|
text_: string;
|
|
9
10
|
status_?: ItemStatus;
|
|
10
11
|
loglevel_: LogLevel;
|
|
11
12
|
ref_?: WeakRef<never>;
|
|
12
13
|
parentId_?: number;
|
|
13
|
-
|
|
14
|
-
|
|
14
|
+
dirty_?: boolean;
|
|
15
|
+
lastLeaf_?: ModelItem;
|
|
16
|
+
tag_?: string;
|
|
17
|
+
context_?: any;
|
|
15
18
|
}
|
|
16
|
-
export declare type Model = {
|
|
17
|
-
items_: ModelItem[];
|
|
19
|
+
export declare type Model = List<ModelItem> & {
|
|
18
20
|
skipLines_: number;
|
|
19
21
|
tick_: number;
|
|
20
22
|
spinning_: number;
|
package/dist/index.cjs
CHANGED
|
@@ -1,13 +1,18 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var appenderUtils = require('@niceties/logger/appender-utils');
|
|
4
|
+
var globalAppender = require('@niceties/logger/global-appender');
|
|
4
5
|
var formatUtils = require('@niceties/logger/format-utils');
|
|
5
6
|
var defaultFormatting = require('@niceties/logger/default-formatting');
|
|
6
|
-
var core
|
|
7
|
+
var core = require('./core.cjs');
|
|
7
8
|
var spinners = require('./spinners.cjs');
|
|
8
9
|
require('draftlog');
|
|
10
|
+
require('@slimlib/list');
|
|
9
11
|
|
|
10
12
|
const supportsUnicode = formatUtils.terminalSupportsUnicode();
|
|
11
13
|
const spinner = supportsUnicode ? spinners.dots : spinners.line;
|
|
12
|
-
const formatter = formatUtils.createFormatter(defaultFormatting.colors, supportsUnicode ? defaultFormatting.unicodePrefixes : defaultFormatting.asciiPrefixes);
|
|
13
|
-
|
|
14
|
+
const formatter = formatUtils.createFormatter(defaultFormatting.colors, supportsUnicode ? defaultFormatting.unicodePrefixes : defaultFormatting.asciiPrefixes, defaultFormatting.tagFactory);
|
|
15
|
+
let minLogLevel = 1 /* info */;
|
|
16
|
+
globalAppender.appender(appenderUtils.filterMessages((message) => message.loglevel >= minLogLevel || message.action !== 3 /* log */, core.createDraftlogAppender(spinner, formatter, false, 2), // eslint-disable-line indent
|
|
17
|
+
{ setMinLevel(logLevel) { minLogLevel = logLevel; } } // eslint-disable-line indent
|
|
18
|
+
));
|
package/dist/index.mjs
CHANGED
|
@@ -1,11 +1,16 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { filterMessages } from '@niceties/logger/appender-utils';
|
|
2
|
+
import { appender } from '@niceties/logger/global-appender';
|
|
2
3
|
import { terminalSupportsUnicode, createFormatter } from '@niceties/logger/format-utils';
|
|
3
|
-
import { colors, unicodePrefixes, asciiPrefixes } from '@niceties/logger/default-formatting';
|
|
4
|
+
import { colors, unicodePrefixes, asciiPrefixes, tagFactory } from '@niceties/logger/default-formatting';
|
|
4
5
|
import { createDraftlogAppender } from './core.mjs';
|
|
5
6
|
import { dots, line } from './spinners.mjs';
|
|
6
7
|
import 'draftlog';
|
|
8
|
+
import '@slimlib/list';
|
|
7
9
|
|
|
8
10
|
const supportsUnicode = terminalSupportsUnicode();
|
|
9
11
|
const spinner = supportsUnicode ? dots : line;
|
|
10
|
-
const formatter = createFormatter(colors, supportsUnicode ? unicodePrefixes : asciiPrefixes);
|
|
11
|
-
|
|
12
|
+
const formatter = createFormatter(colors, supportsUnicode ? unicodePrefixes : asciiPrefixes, tagFactory);
|
|
13
|
+
let minLogLevel = 1 /* info */;
|
|
14
|
+
appender(filterMessages((message) => message.loglevel >= minLogLevel || message.action !== 3 /* log */, createDraftlogAppender(spinner, formatter, false, 2), // eslint-disable-line indent
|
|
15
|
+
{ setMinLevel(logLevel) { minLogLevel = logLevel; } } // eslint-disable-line indent
|
|
16
|
+
));
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "1.0
|
|
2
|
+
"version": "1.2.0",
|
|
3
3
|
"license": "MIT",
|
|
4
4
|
"name": "@niceties/draftlog-appender",
|
|
5
5
|
"author": {
|
|
@@ -17,8 +17,8 @@
|
|
|
17
17
|
"default": "./dist/core.mjs"
|
|
18
18
|
},
|
|
19
19
|
"./spinners": {
|
|
20
|
-
"require": "./
|
|
21
|
-
"default": "./
|
|
20
|
+
"require": "./dist/spinners.cjs",
|
|
21
|
+
"default": "./dist/spinners.mjs"
|
|
22
22
|
}
|
|
23
23
|
},
|
|
24
24
|
"main": "./dist/index.cjs",
|
|
@@ -40,42 +40,38 @@
|
|
|
40
40
|
"url": "https://github.com/kshutkin/niceties/issues"
|
|
41
41
|
},
|
|
42
42
|
"homepage": "https://github.com/kshutkin/niceties/blob/main/draftlog-appender/README.md",
|
|
43
|
+
"readme": "README.md",
|
|
44
|
+
"description": "Appender for '@niceites/logger' implemented using draftlog package.",
|
|
43
45
|
"scripts": {
|
|
44
|
-
"build": "
|
|
45
|
-
"dev": "rimraf ./dist && rollup -c -w",
|
|
46
|
+
"build": "pkgbld",
|
|
46
47
|
"test": "node --expose-gc ../node_modules/jest-cli/bin/jest.js --collectCoverage",
|
|
47
48
|
"lint": "eslint ./src",
|
|
48
49
|
"semantic-release": "npx semantic-release"
|
|
49
50
|
},
|
|
50
51
|
"devDependencies": {
|
|
51
|
-
"@rollup/plugin-commonjs": "21.0.1",
|
|
52
|
-
"@rollup/plugin-node-resolve": "13.0.6",
|
|
53
52
|
"@semantic-release/changelog": "6.0.1",
|
|
54
53
|
"@semantic-release/commit-analyzer": "9.0.1",
|
|
55
54
|
"@semantic-release/git": "10.0.1",
|
|
56
55
|
"@semantic-release/npm": "8.0.2",
|
|
57
56
|
"@semantic-release/release-notes-generator": "10.0.2",
|
|
58
|
-
"@types/jest": "27.0
|
|
59
|
-
"@typescript-eslint/eslint-plugin": "5.
|
|
60
|
-
"@typescript-eslint/parser": "5.
|
|
57
|
+
"@types/jest": "27.4.0",
|
|
58
|
+
"@typescript-eslint/eslint-plugin": "5.11.0",
|
|
59
|
+
"@typescript-eslint/parser": "5.11.0",
|
|
61
60
|
"conventional-changelog-angular": "5.0.13",
|
|
62
|
-
"eslint": "8.
|
|
63
|
-
"jest": "27.
|
|
64
|
-
"lodash": "4.17.21",
|
|
65
|
-
"rimraf": "3.0.2",
|
|
66
|
-
"rollup": "2.60.1",
|
|
67
|
-
"rollup-plugin-terser": "7.0.2",
|
|
68
|
-
"rollup-plugin-typescript2": "0.31.1",
|
|
69
|
-
"rollup-plugin-preprocess": "0.0.4",
|
|
61
|
+
"eslint": "8.8.0",
|
|
62
|
+
"jest": "27.5.1",
|
|
70
63
|
"semantic-release": "18.0.0",
|
|
71
64
|
"semantic-release-monorepo": "7.0.5",
|
|
72
|
-
"ts-jest": "27.
|
|
73
|
-
"typescript": "4.
|
|
74
|
-
"update-monorepo-package-json": "0.
|
|
65
|
+
"ts-jest": "27.1.3",
|
|
66
|
+
"typescript": "4.5.x",
|
|
67
|
+
"update-monorepo-package-json": "0.2.0",
|
|
68
|
+
"pkgbld": "1.1.10"
|
|
75
69
|
},
|
|
76
|
-
"
|
|
77
|
-
"@niceties/logger": "^1.
|
|
78
|
-
"draftlog": "^1.0.13"
|
|
70
|
+
"peerDependencies": {
|
|
71
|
+
"@niceties/logger": "^1.1.1"
|
|
79
72
|
},
|
|
80
|
-
"
|
|
73
|
+
"dependencies": {
|
|
74
|
+
"draftlog": "^1.0.13",
|
|
75
|
+
"@slimlib/list": "^1.0.0"
|
|
76
|
+
}
|
|
81
77
|
}
|