https://github.com/dmzhan/electron-log-unconfig
A very simple logging module for your Electron application with unconfig.
https://github.com/dmzhan/electron-log-unconfig
electron electron-log unconfig
Last synced: 2 months ago
JSON representation
A very simple logging module for your Electron application with unconfig.
- Host: GitHub
- URL: https://github.com/dmzhan/electron-log-unconfig
- Owner: dmZhan
- License: mit
- Created: 2024-05-09T14:40:25.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2024-05-27T02:56:25.000Z (about 2 years ago)
- Last Synced: 2025-06-09T14:08:56.281Z (about 1 year ago)
- Topics: electron, electron-log, unconfig
- Language: JavaScript
- Homepage:
- Size: 74.2 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# electron-log
[](https://www.npmjs.com/packages/electron-log-unconfig)
## Declare
Forked from [`electron-log`](https://github.com/megahertz/electron-log/tree/v4.4.8)@4.4.8
### changes in this fork
- You can add a `.logrc` or `.logrc.json` file in the project root directory and configure the log output method.
- You can add a `.logrc` field to `package.json` and configure the log output method.
- If you don't add config file or field, it works as normal `electron-log`.
## Usage
```bash
npm install electron-log-unconfig -D
```
And then you can add a config file named `.logrc` or `.logrc.json` to root or add a `.logrc` field to `package.json`.
### Options
Both config file and field have samed options.
```json
{
"filePath": "D:/logs",
"fileName": "Test-{y}-{m}-{d}",
"maxSize": 100,
"segmentation": true,
"prefixPkgName": false,
"countLength": 3
}
```
#### filePath
- Required: `false`
- Type: `string`
The log output path.
#### fileName
- Required: `false`
- Type: `string`
File name's template. It will replace with date.
For example(Today is 2024/2/1):
```txt
Test-{y}-{m}-{d} -> filename: Test-2024-2-1.log
Test-{y}-{m} -> filename: Test-2024-2.log
Test-{y} -> filename: Test-2024.log
Test-{y}-AA{m}-BB{d} -> filename: Test-2024-AA2-BB1.log
```
#### maxSize
- Required: `false`
- Type: `number`
- Default: `1024`
Single file's size. The unit ofmeasurement is magabytes.
#### segmentation
- Required: `false`
- Type: `boolean`
- Default: `false`
Whether to enable file splitting.
#### prefixPkgName
- Required: `false`
- Type: `boolean`
- Default: `false`
Whether to add package name as prefix.
#### countLength
- Required: `false`
- Type: `number`
- Default: 3
Default filename(if segmentation is true) is `xxx.001.log`.
If set countLength to 5, filename is `xxx.00001.log`.
## Future
Maybe i will rewrite electron-log.But for now i'm just going to add a few methods to meet my needs.