@log4js-node/smtp 2.0.0 → 2.0.3

Sign up to get free protection for your applications and to get access to all the features.
package/README.md CHANGED
@@ -1,5 +1,7 @@
1
- # SMTP Appender for log4js
2
- [![Build Status](https://travis-ci.com/log4js-node/smtp.svg?branch=master)](https://travis-ci.com/log4js-node/smtp)
1
+ SMTP Appender for log4js [![CodeQL](https://github.com/log4js-node/smtp/actions/workflows/codeql-analysis.yml/badge.svg)](https://github.com/log4js-node/smtp/actions/workflows/codeql-analysis.yml) [![Node.js CI](https://github.com/log4js-node/smtp/actions/workflows/node.js.yml/badge.svg)](https://github.com/log4js-node/smtp/actions/workflows/node.js.yml)
2
+ ===========
3
+
4
+ [![NPM](https://nodei.co/npm/@log4js-node/smtp.png?downloads=true&downloadRank=true&stars=true)](https://nodei.co/npm/@log4js-node/smtp/)
3
5
 
4
6
  Sends log events as emails. If you use this appender, you should also call `log4js.shutdown` when your application closes so that any remaining emails can be sent. Many of the configuration options below are passed through to nodemailer, so you should read their docs to get the most out of this appender.
5
7
 
@@ -30,7 +32,7 @@ npm install @log4js-node/smtp
30
32
  * `subject` - `string` (optional, defaults to message from first log event in batch) - subject for email
31
33
  * `sender` - `string` (optional) - who the logs should be sent as
32
34
  * `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.md)
35
+ * `layout` - `object` (optional, defaults to basicLayout) - see [layouts](https://log4js-node.github.io/log4js-node/layouts.html)
34
36
  * `cc` - `string` (optional) - email addresses to send the carbon-copy logs to
35
37
  * `bcc` - `string` (optional) - email addresses to send the blind-carbon-copy logs to
36
38
 
package/lib/index.js CHANGED
@@ -14,7 +14,6 @@ function getTransportOptions(config) {
14
14
  return options;
15
15
  }
16
16
 
17
-
18
17
  /**
19
18
  * SMTP Appender. Sends logging events using SMTP protocol.
20
19
  * It can either send an email on each event or group several
@@ -38,6 +37,9 @@ function smtpAppender(config, layout, subjectLayout) {
38
37
  const sendInterval = config.sendInterval * 1000 || 0;
39
38
  const shutdownTimeout = ('shutdownTimeout' in config ? config.shutdownTimeout : 5) * 1000;
40
39
  const transport = mailer.createTransport(getTransportOptions(config));
40
+ transport.on('error', (error) => {
41
+ console.error('log4js.smtpAppender - Error happened', error); // eslint-disable-line no-console
42
+ });
41
43
  const logEventBuffer = [];
42
44
 
43
45
  let unsentCount = 0;
@@ -78,7 +80,7 @@ function smtpAppender(config, layout, subjectLayout) {
78
80
  }
79
81
  transport.sendMail(msg, (error) => {
80
82
  if (error) {
81
- console.error('log4js.smtpAppender - Error happened', error); //eslint-disable-line
83
+ console.error('log4js.smtpAppender - Send mail error happened', error); // eslint-disable-line no-console
82
84
  }
83
85
  transport.close();
84
86
  unsentCount -= count;
@@ -137,5 +139,4 @@ function configure(config, layouts) {
137
139
  return smtpAppender(config, layout, subjectLayout);
138
140
  }
139
141
 
140
-
141
142
  module.exports.configure = configure;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@log4js-node/smtp",
3
- "version": "2.0.0",
3
+ "version": "2.0.3",
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.1.0",
44
- "nodemailer": "^6.6.1"
44
+ "debug": "^4.3.3",
45
+ "nodemailer": "^6.7.2"
45
46
  },
46
47
  "devDependencies": {
47
- "@log4js-node/sandboxed-module": "^2.1.1",
48
- "codecov": "^3.0.0",
49
- "conventional-changelog": "^1.1.15",
50
- "eslint": "^4.10.0",
51
- "eslint-config-airbnb-base": "^12.1.0",
52
- "eslint-import-resolver-node": "^0.3.1",
53
- "eslint-plugin-import": "^2.8.0",
54
- "husky": "^0.14.3",
55
- "nyc": "^11.5.0",
56
- "tap": "^12.0.1",
48
+ "@log4js-node/sandboxed-module": "^2.2.1",
49
+ "codecov": "^3.8.3",
50
+ "conventional-changelog": "^3.1.25",
51
+ "eslint": "^8.11.0",
52
+ "eslint-config-airbnb-base": "^15.0.0",
53
+ "eslint-import-resolver-node": "^0.3.6",
54
+ "eslint-plugin-import": "^2.25.4",
55
+ "husky": "^7.0.4",
56
+ "nyc": "^15.1.0",
57
+ "tap": "^16.0.0",
58
+ "typescript": "^4.6.2",
57
59
  "validate-commit-msg": "^2.14.0"
58
60
  },
59
61
  "browser": {
package/types/index.d.ts CHANGED
@@ -1,5 +1,63 @@
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
+ export interface Level {
20
+ isEqualTo(other: string): boolean;
21
+ isEqualTo(otherLevel: Level): boolean;
22
+ isLessThanOrEqualTo(other: string): boolean;
23
+ isLessThanOrEqualTo(otherLevel: Level): boolean;
24
+ isGreaterThanOrEqualTo(other: string): boolean;
25
+ isGreaterThanOrEqualTo(otherLevel: Level): boolean;
26
+ colour: string;
27
+ level: number;
28
+ levelStr: string;
29
+ }
30
+
31
+ export interface LoggingEvent {
32
+ categoryName: string; // name of category
33
+ level: Level; // level of message
34
+ data: any[]; // objects to log
35
+ startTime: Date;
36
+ pid: number;
37
+ context: any;
38
+ cluster?: {
39
+ workerId: number;
40
+ worker: number;
41
+ };
42
+ }
43
+
44
+ export type Token = ((logEvent: LoggingEvent) => string) | string;
45
+
46
+ export interface PatternLayout {
47
+ type: 'pattern';
48
+ // specifier for the output format, using placeholders as described below
49
+ pattern: string;
50
+ // user-defined tokens to be used in the pattern
51
+ tokens?: { [name: string]: Token };
52
+ }
53
+
54
+ export interface CustomLayout {
55
+ [key: string]: any;
56
+ type: string;
57
+ }
58
+
59
+ export type Layout = BaseLayout | ColoredLayout | MessagePassThroughLayout | DummyLayout | PatternLayout | CustomLayout;
60
+
3
61
  export interface SmtpAppender {
4
62
  type: '@log4js-node/smtp';
5
63
  // (if not present will use transport field)
@@ -50,4 +108,4 @@ export interface SmtpAppender {
50
108
  bcc?: string;
51
109
  }
52
110
 
53
- export type Appender = Appender | SmtpAppender;
111
+ export type Appender = SmtpAppender;
@@ -0,0 +1,9 @@
1
+ {
2
+ "compileOnSave": false,
3
+ "compilerOptions": {
4
+ "strict": true,
5
+ "noUnusedParameters": true,
6
+ "noUnusedLocals": false,
7
+ "noEmit": true
8
+ }
9
+ }