Skip to content

Commit 986ecf0

Browse files
committed
feat: move formatters to main package; consolidate format and writing to transport
1 parent 1afa14a commit 986ecf0

File tree

3 files changed

+5
-31
lines changed

3 files changed

+5
-31
lines changed

electron/common/logger/__mocks__/log-formatter.mock.ts

-11
This file was deleted.

electron/common/logger/types.ts

+5-20
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import type { Maybe } from '../types.js';
2-
31
/**
42
* Originally, I used the `electron-log` module (https://github.com/megahertz/electron-log)
53
* but at some point it stopped writing logs from renderer to a file.
@@ -25,32 +23,19 @@ export type LogMessage = LogData & {
2523
};
2624

2725
/**
28-
* Formats log messages into strings to be written to transporters.
29-
* Return `undefined` to skip logging the message.
30-
*/
31-
export interface LogFormatter {
32-
format(message: LogMessage): Maybe<string>;
33-
}
34-
35-
/**
36-
* Transporters write formatted messages somewhere.
37-
* For example, to the console, a file, an api, or nowhere.
38-
* What the string looks like is up to the formatter.
26+
* Transporters write log messages somewhere.
27+
* For example, to a console, a file, an api, or nowhere.
3928
*/
4029
export interface LogTransporter {
41-
transport(message: string): void;
30+
transport(message: LogMessage): void;
4231
}
4332

4433
export interface LogTransportConfig {
4534
/**
46-
* Transports formatted log lines somewhere.
47-
* Could write them to a console, to a file, or ship to a remote system.
35+
* Transports log messages somewhere.
36+
* For example, to the console, a file, an api, or nowhere.
4837
*/
4938
transporter: LogTransporter;
50-
/**
51-
* Formats log data objects into strings to write to the transporter.
52-
*/
53-
formatter: LogFormatter;
5439
/**
5540
* By default, all messages are logged to every transporter for levels
5641
* that satisify the runtime log level. You can further restrict which

0 commit comments

Comments
 (0)