@log4js-node/smtp 1.1.0 → 2.0.2

Sign up to get free protection for your applications and to get access to all the features.
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.md)
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 - Error happened', error); //eslint-disable-line
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": "1.1.0",
3
+ "version": "2.0.2",
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": "^4.6.4"
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.10.0",
52
+ "eslint-config-airbnb-base": "^13.2.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": "^15.1.6",
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
+ }