@hocuspocus/extension-logger 3.4.5-rc.0 → 3.4.6-rc.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/package.json +2 -2
- package/dist/index.js +0 -64
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hocuspocus/extension-logger",
|
|
3
|
-
"version": "3.4.
|
|
3
|
+
"version": "3.4.6-rc.1",
|
|
4
4
|
"description": "hocuspocus logging extension",
|
|
5
5
|
"homepage": "https://hocuspocus.dev",
|
|
6
6
|
"keywords": [
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"dist"
|
|
30
30
|
],
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@hocuspocus/server": "^3.4.
|
|
32
|
+
"@hocuspocus/server": "^3.4.6-rc.1"
|
|
33
33
|
},
|
|
34
34
|
"gitHead": "b3454a4ca289a84ddfb7fa5607a2d4b8d5c37e9d",
|
|
35
35
|
"repository": {
|
package/dist/index.js
DELETED
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
//#region packages/extension-logger/src/Logger.ts
|
|
2
|
-
var Logger = class {
|
|
3
|
-
/**
|
|
4
|
-
* Constructor
|
|
5
|
-
*/
|
|
6
|
-
constructor(configuration) {
|
|
7
|
-
this.name = null;
|
|
8
|
-
this.configuration = {
|
|
9
|
-
prefix: null,
|
|
10
|
-
onLoadDocument: true,
|
|
11
|
-
onChange: true,
|
|
12
|
-
onStoreDocument: true,
|
|
13
|
-
onConnect: true,
|
|
14
|
-
onDisconnect: true,
|
|
15
|
-
onUpgrade: true,
|
|
16
|
-
onRequest: true,
|
|
17
|
-
onDestroy: true,
|
|
18
|
-
onConfigure: true,
|
|
19
|
-
log: console.log
|
|
20
|
-
};
|
|
21
|
-
this.configuration = {
|
|
22
|
-
...this.configuration,
|
|
23
|
-
...configuration
|
|
24
|
-
};
|
|
25
|
-
}
|
|
26
|
-
async onConfigure(data) {
|
|
27
|
-
this.name = data.instance.configuration.name;
|
|
28
|
-
if (!this.configuration.onConfigure) return;
|
|
29
|
-
if (this.configuration.prefix) console.warn("[hocuspocus warn] The Logger 'prefix' is deprecated. Pass a 'name' to the Hocuspocus configuration instead.");
|
|
30
|
-
}
|
|
31
|
-
async onLoadDocument(data) {
|
|
32
|
-
if (this.configuration.onLoadDocument) this.log(`Loaded document "${data.documentName}".`);
|
|
33
|
-
}
|
|
34
|
-
async onChange(data) {
|
|
35
|
-
if (this.configuration.onChange) this.log(`Document "${data.documentName}" changed.`);
|
|
36
|
-
}
|
|
37
|
-
async onStoreDocument(data) {
|
|
38
|
-
if (this.configuration.onStoreDocument) this.log(`Store "${data.documentName}".`);
|
|
39
|
-
}
|
|
40
|
-
async onConnect(data) {
|
|
41
|
-
if (this.configuration.onConnect) this.log(`New connection to "${data.documentName}".`);
|
|
42
|
-
}
|
|
43
|
-
async onDisconnect(data) {
|
|
44
|
-
if (this.configuration.onDisconnect) this.log(`Connection to "${data.documentName}" closed.`);
|
|
45
|
-
}
|
|
46
|
-
async onUpgrade(data) {
|
|
47
|
-
if (this.configuration.onUpgrade) this.log("Upgrading connection …");
|
|
48
|
-
}
|
|
49
|
-
async onRequest(data) {
|
|
50
|
-
if (this.configuration.onRequest) this.log(`Incoming HTTP Request to ${data.request.url}`);
|
|
51
|
-
}
|
|
52
|
-
async onDestroy(data) {
|
|
53
|
-
if (this.configuration.onDestroy) this.log("Shut down.");
|
|
54
|
-
}
|
|
55
|
-
log(message) {
|
|
56
|
-
let meta = `${(/* @__PURE__ */ new Date()).toISOString()}`;
|
|
57
|
-
if (this.name) meta = `${this.name} ${meta}`;
|
|
58
|
-
message = `[${meta}] ${message}`;
|
|
59
|
-
this.configuration.log(message);
|
|
60
|
-
}
|
|
61
|
-
};
|
|
62
|
-
|
|
63
|
-
//#endregion
|
|
64
|
-
export { Logger };
|