@loglayer/transport-electron-log 1.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/LICENSE +21 -0
- package/README.md +34 -0
- package/dist/index.cjs +34 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +8 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +34 -0
- package/dist/index.js.map +1 -0
- package/package.json +59 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Theo Gravity
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# Electron-log Transport for LogLayer
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/@loglayer/transport-electron-log)
|
|
4
|
+

|
|
5
|
+
[](http://www.typescriptlang.org/)
|
|
6
|
+
|
|
7
|
+
[Electron-log](https://github.com/megahertz/electron-log) is a logging library designed specifically for Electron applications.
|
|
8
|
+
|
|
9
|
+
## Installation
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
npm install loglayer @loglayer/transport-electron-log electron-log
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Usage
|
|
16
|
+
|
|
17
|
+
```typescript
|
|
18
|
+
// Main process logger
|
|
19
|
+
import log from 'electron-log/src/main'
|
|
20
|
+
// Or for Renderer process
|
|
21
|
+
// import log from 'electron-log/src/renderer'
|
|
22
|
+
import { LogLayer } from 'loglayer'
|
|
23
|
+
import { ElectronLogTransport } from "@loglayer/transport-electron-log"
|
|
24
|
+
|
|
25
|
+
const logger = new LogLayer({
|
|
26
|
+
transport: new ElectronLogTransport({
|
|
27
|
+
logger: log
|
|
28
|
+
})
|
|
29
|
+
})
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Documentation
|
|
33
|
+
|
|
34
|
+
For more details, visit [https://loglayer.dev/transports/electron-log](https://loglayer.dev/transports/electron-log)
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});// src/ElectronLogTransport.ts
|
|
2
|
+
var _transport = require('@loglayer/transport');
|
|
3
|
+
var ElectronLogTransport = class extends _transport.BaseTransport {
|
|
4
|
+
shipToLogger({ logLevel, messages, data, hasData }) {
|
|
5
|
+
if (data && hasData) {
|
|
6
|
+
messages.push(data);
|
|
7
|
+
}
|
|
8
|
+
switch (logLevel) {
|
|
9
|
+
case _transport.LogLevel.info:
|
|
10
|
+
this.logger.info(...messages);
|
|
11
|
+
break;
|
|
12
|
+
case _transport.LogLevel.warn:
|
|
13
|
+
this.logger.warn(...messages);
|
|
14
|
+
break;
|
|
15
|
+
case _transport.LogLevel.error:
|
|
16
|
+
this.logger.error(...messages);
|
|
17
|
+
break;
|
|
18
|
+
case _transport.LogLevel.trace:
|
|
19
|
+
this.logger.debug(...messages);
|
|
20
|
+
break;
|
|
21
|
+
case _transport.LogLevel.debug:
|
|
22
|
+
this.logger.debug(...messages);
|
|
23
|
+
break;
|
|
24
|
+
case _transport.LogLevel.fatal:
|
|
25
|
+
this.logger.error(...messages);
|
|
26
|
+
break;
|
|
27
|
+
}
|
|
28
|
+
return messages;
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
exports.ElectronLogTransport = ElectronLogTransport;
|
|
34
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/loglayer/loglayer/packages/transports/electron-log/dist/index.cjs","../src/ElectronLogTransport.ts"],"names":[],"mappings":"AAAA;ACAA,gDAAsE;AAG/D,IAAM,qBAAA,EAAN,MAAA,QAAmC,yBAAiC;AAAA,EACzE,YAAA,CAAa,EAAE,QAAA,EAAU,QAAA,EAAU,IAAA,EAAM,QAAQ,CAAA,EAA4B;AAC3E,IAAA,GAAA,CAAI,KAAA,GAAQ,OAAA,EAAS;AAEnB,MAAA,QAAA,CAAS,IAAA,CAAK,IAAI,CAAA;AAAA,IACpB;AAEA,IAAA,OAAA,CAAQ,QAAA,EAAU;AAAA,MAChB,KAAK,mBAAA,CAAS,IAAA;AAEZ,QAAA,IAAA,CAAK,MAAA,CAAO,IAAA,CAAK,GAAG,QAAQ,CAAA;AAC5B,QAAA,KAAA;AAAA,MACF,KAAK,mBAAA,CAAS,IAAA;AAEZ,QAAA,IAAA,CAAK,MAAA,CAAO,IAAA,CAAK,GAAG,QAAQ,CAAA;AAC5B,QAAA,KAAA;AAAA,MACF,KAAK,mBAAA,CAAS,KAAA;AAEZ,QAAA,IAAA,CAAK,MAAA,CAAO,KAAA,CAAM,GAAG,QAAQ,CAAA;AAC7B,QAAA,KAAA;AAAA,MACF,KAAK,mBAAA,CAAS,KAAA;AAEZ,QAAA,IAAA,CAAK,MAAA,CAAO,KAAA,CAAM,GAAG,QAAQ,CAAA;AAC7B,QAAA,KAAA;AAAA,MACF,KAAK,mBAAA,CAAS,KAAA;AAEZ,QAAA,IAAA,CAAK,MAAA,CAAO,KAAA,CAAM,GAAG,QAAQ,CAAA;AAC7B,QAAA,KAAA;AAAA,MACF,KAAK,mBAAA,CAAS,KAAA;AAEZ,QAAA,IAAA,CAAK,MAAA,CAAO,KAAA,CAAM,GAAG,QAAQ,CAAA;AAC7B,QAAA,KAAA;AAAA,IACJ;AAEA,IAAA,OAAO,QAAA;AAAA,EACT;AACF,CAAA;ADTA;AACE;AACF,oDAAC","file":"/home/runner/work/loglayer/loglayer/packages/transports/electron-log/dist/index.cjs","sourcesContent":[null,"import { BaseTransport, type LogLayerTransportParams, LogLevel } from \"@loglayer/transport\";\nimport type Logger from \"electron-log\";\n\nexport class ElectronLogTransport extends BaseTransport<Logger.MainLogger> {\n shipToLogger({ logLevel, messages, data, hasData }: LogLayerTransportParams) {\n if (data && hasData) {\n // library wants the data object to be the last parameter\n messages.push(data);\n }\n\n switch (logLevel) {\n case LogLevel.info:\n // @ts-ignore\n this.logger.info(...messages);\n break;\n case LogLevel.warn:\n // @ts-ignore\n this.logger.warn(...messages);\n break;\n case LogLevel.error:\n // @ts-ignore\n this.logger.error(...messages);\n break;\n case LogLevel.trace:\n // @ts-ignore\n this.logger.debug(...messages);\n break;\n case LogLevel.debug:\n // @ts-ignore\n this.logger.debug(...messages);\n break;\n case LogLevel.fatal:\n // @ts-ignore\n this.logger.error(...messages);\n break;\n }\n\n return messages;\n }\n}\n"]}
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { BaseTransport, LogLayerTransportParams } from '@loglayer/transport';
|
|
2
|
+
import Logger from 'electron-log';
|
|
3
|
+
|
|
4
|
+
declare class ElectronLogTransport extends BaseTransport<Logger.MainLogger> {
|
|
5
|
+
shipToLogger({ logLevel, messages, data, hasData }: LogLayerTransportParams): any[];
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export { ElectronLogTransport };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { BaseTransport, LogLayerTransportParams } from '@loglayer/transport';
|
|
2
|
+
import Logger from 'electron-log';
|
|
3
|
+
|
|
4
|
+
declare class ElectronLogTransport extends BaseTransport<Logger.MainLogger> {
|
|
5
|
+
shipToLogger({ logLevel, messages, data, hasData }: LogLayerTransportParams): any[];
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export { ElectronLogTransport };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
// src/ElectronLogTransport.ts
|
|
2
|
+
import { BaseTransport, LogLevel } from "@loglayer/transport";
|
|
3
|
+
var ElectronLogTransport = class extends BaseTransport {
|
|
4
|
+
shipToLogger({ logLevel, messages, data, hasData }) {
|
|
5
|
+
if (data && hasData) {
|
|
6
|
+
messages.push(data);
|
|
7
|
+
}
|
|
8
|
+
switch (logLevel) {
|
|
9
|
+
case LogLevel.info:
|
|
10
|
+
this.logger.info(...messages);
|
|
11
|
+
break;
|
|
12
|
+
case LogLevel.warn:
|
|
13
|
+
this.logger.warn(...messages);
|
|
14
|
+
break;
|
|
15
|
+
case LogLevel.error:
|
|
16
|
+
this.logger.error(...messages);
|
|
17
|
+
break;
|
|
18
|
+
case LogLevel.trace:
|
|
19
|
+
this.logger.debug(...messages);
|
|
20
|
+
break;
|
|
21
|
+
case LogLevel.debug:
|
|
22
|
+
this.logger.debug(...messages);
|
|
23
|
+
break;
|
|
24
|
+
case LogLevel.fatal:
|
|
25
|
+
this.logger.error(...messages);
|
|
26
|
+
break;
|
|
27
|
+
}
|
|
28
|
+
return messages;
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
export {
|
|
32
|
+
ElectronLogTransport
|
|
33
|
+
};
|
|
34
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/ElectronLogTransport.ts"],"sourcesContent":["import { BaseTransport, type LogLayerTransportParams, LogLevel } from \"@loglayer/transport\";\nimport type Logger from \"electron-log\";\n\nexport class ElectronLogTransport extends BaseTransport<Logger.MainLogger> {\n shipToLogger({ logLevel, messages, data, hasData }: LogLayerTransportParams) {\n if (data && hasData) {\n // library wants the data object to be the last parameter\n messages.push(data);\n }\n\n switch (logLevel) {\n case LogLevel.info:\n // @ts-ignore\n this.logger.info(...messages);\n break;\n case LogLevel.warn:\n // @ts-ignore\n this.logger.warn(...messages);\n break;\n case LogLevel.error:\n // @ts-ignore\n this.logger.error(...messages);\n break;\n case LogLevel.trace:\n // @ts-ignore\n this.logger.debug(...messages);\n break;\n case LogLevel.debug:\n // @ts-ignore\n this.logger.debug(...messages);\n break;\n case LogLevel.fatal:\n // @ts-ignore\n this.logger.error(...messages);\n break;\n }\n\n return messages;\n }\n}\n"],"mappings":";AAAA,SAAS,eAA6C,gBAAgB;AAG/D,IAAM,uBAAN,cAAmC,cAAiC;AAAA,EACzE,aAAa,EAAE,UAAU,UAAU,MAAM,QAAQ,GAA4B;AAC3E,QAAI,QAAQ,SAAS;AAEnB,eAAS,KAAK,IAAI;AAAA,IACpB;AAEA,YAAQ,UAAU;AAAA,MAChB,KAAK,SAAS;AAEZ,aAAK,OAAO,KAAK,GAAG,QAAQ;AAC5B;AAAA,MACF,KAAK,SAAS;AAEZ,aAAK,OAAO,KAAK,GAAG,QAAQ;AAC5B;AAAA,MACF,KAAK,SAAS;AAEZ,aAAK,OAAO,MAAM,GAAG,QAAQ;AAC7B;AAAA,MACF,KAAK,SAAS;AAEZ,aAAK,OAAO,MAAM,GAAG,QAAQ;AAC7B;AAAA,MACF,KAAK,SAAS;AAEZ,aAAK,OAAO,MAAM,GAAG,QAAQ;AAC7B;AAAA,MACF,KAAK,SAAS;AAEZ,aAAK,OAAO,MAAM,GAAG,QAAQ;AAC7B;AAAA,IACJ;AAEA,WAAO;AAAA,EACT;AACF;","names":[]}
|
package/package.json
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@loglayer/transport-electron-log",
|
|
3
|
+
"description": "electron-log transport for loglayer.",
|
|
4
|
+
"version": "1.0.0",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.cjs",
|
|
7
|
+
"module": "./dist/index.js",
|
|
8
|
+
"exports": {
|
|
9
|
+
"import": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"import": "./dist/index.js"
|
|
12
|
+
},
|
|
13
|
+
"require": {
|
|
14
|
+
"types": "./dist/index.d.cts",
|
|
15
|
+
"require": "./dist/index.cjs"
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
"types": "./dist/index.d.ts",
|
|
19
|
+
"license": "MIT",
|
|
20
|
+
"repository": "loglayer/loglayer.git",
|
|
21
|
+
"author": "Theo Gravity <theo@suteki.nu>",
|
|
22
|
+
"keywords": [
|
|
23
|
+
"logging",
|
|
24
|
+
"log",
|
|
25
|
+
"loglayer",
|
|
26
|
+
"electron-log",
|
|
27
|
+
"transport"
|
|
28
|
+
],
|
|
29
|
+
"dependencies": {
|
|
30
|
+
"@loglayer/transport": "1.0.0"
|
|
31
|
+
},
|
|
32
|
+
"devDependencies": {
|
|
33
|
+
"hash-runner": "2.0.1",
|
|
34
|
+
"@types/node": "22.10.3",
|
|
35
|
+
"tsup": "8.3.5",
|
|
36
|
+
"typescript": "5.7.2",
|
|
37
|
+
"vitest": "2.1.8",
|
|
38
|
+
"loglayer": "5.0.0",
|
|
39
|
+
"@internal/tsconfig": "1.0.0"
|
|
40
|
+
},
|
|
41
|
+
"peerDependencies": {
|
|
42
|
+
"electron-log": "*"
|
|
43
|
+
},
|
|
44
|
+
"bugs": "https://github.com/loglayer/loglayer/issues",
|
|
45
|
+
"engines": {
|
|
46
|
+
"node": ">=18"
|
|
47
|
+
},
|
|
48
|
+
"files": [
|
|
49
|
+
"dist"
|
|
50
|
+
],
|
|
51
|
+
"homepage": "https://loglayer.dev",
|
|
52
|
+
"scripts": {
|
|
53
|
+
"build": "tsup src/index.ts",
|
|
54
|
+
"build:dev": "hash-runner",
|
|
55
|
+
"clean": "rm -rf .turbo node_modules dist",
|
|
56
|
+
"lint": "biome check --write --unsafe src && biome format src --write && biome lint src --fix",
|
|
57
|
+
"verify-types": "tsc --noEmit"
|
|
58
|
+
}
|
|
59
|
+
}
|