@log4js-node/smtp 2.0.0 → 2.0.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/README.md +1 -1
- package/lib/index.js +4 -1
- package/package.json +12 -10
- package/types/index.d.ts +60 -1
- package/types/tsconfig.json +9 -0
package/README.md
CHANGED
@@ -30,7 +30,7 @@ npm install @log4js-node/smtp
|
|
30
30
|
* `subject` - `string` (optional, defaults to message from first log event in batch) - subject for email
|
31
31
|
* `sender` - `string` (optional) - who the logs should be sent as
|
32
32
|
* `html` - `boolean` (optional, defaults to `false`) - send the email as HTML instead of plain text
|
33
|
-
* `layout` - `object` (optional, defaults to basicLayout) - see [layouts](layouts.
|
33
|
+
* `layout` - `object` (optional, defaults to basicLayout) - see [layouts](https://log4js-node.github.io/log4js-node/layouts.html)
|
34
34
|
* `cc` - `string` (optional) - email addresses to send the carbon-copy logs to
|
35
35
|
* `bcc` - `string` (optional) - email addresses to send the blind-carbon-copy logs to
|
36
36
|
|
package/lib/index.js
CHANGED
@@ -38,6 +38,9 @@ function smtpAppender(config, layout, subjectLayout) {
|
|
38
38
|
const sendInterval = config.sendInterval * 1000 || 0;
|
39
39
|
const shutdownTimeout = ('shutdownTimeout' in config ? config.shutdownTimeout : 5) * 1000;
|
40
40
|
const transport = mailer.createTransport(getTransportOptions(config));
|
41
|
+
transport.on('error', (error) => {
|
42
|
+
console.error('log4js.smtpAppender - Error happened', error); // eslint-disable-line no-console
|
43
|
+
});
|
41
44
|
const logEventBuffer = [];
|
42
45
|
|
43
46
|
let unsentCount = 0;
|
@@ -78,7 +81,7 @@ function smtpAppender(config, layout, subjectLayout) {
|
|
78
81
|
}
|
79
82
|
transport.sendMail(msg, (error) => {
|
80
83
|
if (error) {
|
81
|
-
console.error('log4js.smtpAppender -
|
84
|
+
console.error('log4js.smtpAppender - Send mail error happened', error); // eslint-disable-line no-console
|
82
85
|
}
|
83
86
|
transport.close();
|
84
87
|
unsentCount -= count;
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@log4js-node/smtp",
|
3
|
-
"version": "2.0.
|
3
|
+
"version": "2.0.1",
|
4
4
|
"description": "SMTP Appender for log4js-node",
|
5
5
|
"homepage": "https://log4js-node.github.io/log4js-node/",
|
6
6
|
"files": [
|
@@ -33,6 +33,7 @@
|
|
33
33
|
"commitmsg": "validate-commit-msg",
|
34
34
|
"pretest": "eslint 'lib/**/*.js' 'test/**/*.js'",
|
35
35
|
"test": "tap 'test/tap/**/*.js' --100",
|
36
|
+
"typings": "tsc -p types/tsconfig.json",
|
36
37
|
"codecov": "tap 'test/tap/**/*.js' --cov --coverage-report=lcov && codecov"
|
37
38
|
},
|
38
39
|
"directories": {
|
@@ -40,20 +41,21 @@
|
|
40
41
|
"lib": "lib"
|
41
42
|
},
|
42
43
|
"dependencies": {
|
43
|
-
"debug": "^3.
|
44
|
-
"nodemailer": "^6.
|
44
|
+
"debug": "^4.3.3",
|
45
|
+
"nodemailer": "^6.7.2"
|
45
46
|
},
|
46
47
|
"devDependencies": {
|
47
|
-
"@log4js-node/sandboxed-module": "^2.
|
48
|
+
"@log4js-node/sandboxed-module": "^2.2.1",
|
48
49
|
"codecov": "^3.0.0",
|
49
|
-
"conventional-changelog": "^
|
50
|
-
"eslint": "^
|
51
|
-
"eslint-config-airbnb-base": "^
|
50
|
+
"conventional-changelog": "^3.1.25",
|
51
|
+
"eslint": "^8.7.0",
|
52
|
+
"eslint-config-airbnb-base": "^13.2.0",
|
52
53
|
"eslint-import-resolver-node": "^0.3.1",
|
53
54
|
"eslint-plugin-import": "^2.8.0",
|
54
|
-
"husky": "^0.
|
55
|
-
"nyc": "^
|
56
|
-
"tap": "^
|
55
|
+
"husky": "^7.0.4",
|
56
|
+
"nyc": "^15.1.0",
|
57
|
+
"tap": "^15.1.6",
|
58
|
+
"typescript": "^4.5.5",
|
57
59
|
"validate-commit-msg": "^2.14.0"
|
58
60
|
},
|
59
61
|
"browser": {
|
package/types/index.d.ts
CHANGED
@@ -1,5 +1,64 @@
|
|
1
1
|
// Type definitions for log4js SMTP appender
|
2
2
|
|
3
|
+
export interface BaseLayout {
|
4
|
+
type: 'basic';
|
5
|
+
}
|
6
|
+
|
7
|
+
export interface ColoredLayout {
|
8
|
+
type: 'colored' | 'coloured';
|
9
|
+
}
|
10
|
+
|
11
|
+
export interface MessagePassThroughLayout {
|
12
|
+
type: 'messagePassThrough';
|
13
|
+
}
|
14
|
+
|
15
|
+
export interface DummyLayout {
|
16
|
+
type: 'dummy';
|
17
|
+
}
|
18
|
+
|
19
|
+
|
20
|
+
export interface Level {
|
21
|
+
isEqualTo(other: string): boolean;
|
22
|
+
isEqualTo(otherLevel: Level): boolean;
|
23
|
+
isLessThanOrEqualTo(other: string): boolean;
|
24
|
+
isLessThanOrEqualTo(otherLevel: Level): boolean;
|
25
|
+
isGreaterThanOrEqualTo(other: string): boolean;
|
26
|
+
isGreaterThanOrEqualTo(otherLevel: Level): boolean;
|
27
|
+
colour: string;
|
28
|
+
level: number;
|
29
|
+
levelStr: string;
|
30
|
+
}
|
31
|
+
|
32
|
+
export interface LoggingEvent {
|
33
|
+
categoryName: string; // name of category
|
34
|
+
level: Level; // level of message
|
35
|
+
data: any[]; // objects to log
|
36
|
+
startTime: Date;
|
37
|
+
pid: number;
|
38
|
+
context: any;
|
39
|
+
cluster?: {
|
40
|
+
workerId: number;
|
41
|
+
worker: number;
|
42
|
+
};
|
43
|
+
}
|
44
|
+
|
45
|
+
export type Token = ((logEvent: LoggingEvent) => string) | string;
|
46
|
+
|
47
|
+
export interface PatternLayout {
|
48
|
+
type: 'pattern';
|
49
|
+
// specifier for the output format, using placeholders as described below
|
50
|
+
pattern: string;
|
51
|
+
// user-defined tokens to be used in the pattern
|
52
|
+
tokens?: { [name: string]: Token };
|
53
|
+
}
|
54
|
+
|
55
|
+
export interface CustomLayout {
|
56
|
+
[key: string]: any;
|
57
|
+
type: string;
|
58
|
+
}
|
59
|
+
|
60
|
+
export type Layout = BaseLayout | ColoredLayout | MessagePassThroughLayout | DummyLayout | PatternLayout | CustomLayout;
|
61
|
+
|
3
62
|
export interface SmtpAppender {
|
4
63
|
type: '@log4js-node/smtp';
|
5
64
|
// (if not present will use transport field)
|
@@ -50,4 +109,4 @@ export interface SmtpAppender {
|
|
50
109
|
bcc?: string;
|
51
110
|
}
|
52
111
|
|
53
|
-
export type Appender =
|
112
|
+
export type Appender = SmtpAppender;
|