diff options
author | Chocobozzz <me@florianbigard.com> | 2018-03-22 11:32:43 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2018-03-22 11:47:26 +0100 |
commit | 05e67d6206669b4a17e786038b1923e79bacb196 (patch) | |
tree | ea0eb0ed4ea6944f7bf847e1d4497893019d83ed | |
parent | 5a649344ffd0e8ac87ca1b573e57156d659f8b9d (diff) | |
download | PeerTube-05e67d6206669b4a17e786038b1923e79bacb196.tar.gz PeerTube-05e67d6206669b4a17e786038b1923e79bacb196.tar.zst PeerTube-05e67d6206669b4a17e786038b1923e79bacb196.zip |
Add logging for emails
-rw-r--r-- | server/helpers/logger.ts | 30 | ||||
-rw-r--r-- | server/lib/emailer.ts | 4 | ||||
-rw-r--r-- | support/doc/tools.md | 21 |
3 files changed, 43 insertions, 12 deletions
diff --git a/server/helpers/logger.ts b/server/helpers/logger.ts index e0b904950..7968b5ec9 100644 --- a/server/helpers/logger.ts +++ b/server/helpers/logger.ts | |||
@@ -73,11 +73,39 @@ const logger = new winston.createLogger({ | |||
73 | exitOnError: true | 73 | exitOnError: true |
74 | }) | 74 | }) |
75 | 75 | ||
76 | function bunyanLogFactory (level: string) { | ||
77 | return function () { | ||
78 | let meta = null | ||
79 | let args = [].concat(arguments) | ||
80 | |||
81 | if (arguments[ 0 ] instanceof Error) { | ||
82 | meta = arguments[ 0 ].toString() | ||
83 | args = Array.prototype.slice.call(arguments, 1) | ||
84 | args.push(meta) | ||
85 | } else if (typeof (args[ 0 ]) !== 'string') { | ||
86 | meta = arguments[ 0 ] | ||
87 | args = Array.prototype.slice.call(arguments, 1) | ||
88 | args.push(meta) | ||
89 | } | ||
90 | |||
91 | logger[ level ].apply(logger, args) | ||
92 | } | ||
93 | } | ||
94 | const bunyanLogger = { | ||
95 | trace: bunyanLogFactory('debug'), | ||
96 | debug: bunyanLogFactory('debug'), | ||
97 | info: bunyanLogFactory('info'), | ||
98 | warn: bunyanLogFactory('warn'), | ||
99 | error: bunyanLogFactory('error'), | ||
100 | fatal: bunyanLogFactory('error') | ||
101 | } | ||
102 | |||
76 | // --------------------------------------------------------------------------- | 103 | // --------------------------------------------------------------------------- |
77 | 104 | ||
78 | export { | 105 | export { |
79 | timestampFormatter, | 106 | timestampFormatter, |
80 | labelFormatter, | 107 | labelFormatter, |
81 | consoleLoggerFormat, | 108 | consoleLoggerFormat, |
82 | logger | 109 | logger, |
110 | bunyanLogger | ||
83 | } | 111 | } |
diff --git a/server/lib/emailer.ts b/server/lib/emailer.ts index bc0061c99..9c105a575 100644 --- a/server/lib/emailer.ts +++ b/server/lib/emailer.ts | |||
@@ -1,7 +1,7 @@ | |||
1 | import { createTransport, Transporter } from 'nodemailer' | 1 | import { createTransport, Transporter } from 'nodemailer' |
2 | import { UserRight } from '../../shared/models/users' | 2 | import { UserRight } from '../../shared/models/users' |
3 | import { isTestInstance } from '../helpers/core-utils' | 3 | import { isTestInstance } from '../helpers/core-utils' |
4 | import { logger } from '../helpers/logger' | 4 | import { bunyanLogger, logger } from '../helpers/logger' |
5 | import { CONFIG } from '../initializers' | 5 | import { CONFIG } from '../initializers' |
6 | import { UserModel } from '../models/account/user' | 6 | import { UserModel } from '../models/account/user' |
7 | import { VideoModel } from '../models/video/video' | 7 | import { VideoModel } from '../models/video/video' |
@@ -44,6 +44,8 @@ class Emailer { | |||
44 | host: CONFIG.SMTP.HOSTNAME, | 44 | host: CONFIG.SMTP.HOSTNAME, |
45 | port: CONFIG.SMTP.PORT, | 45 | port: CONFIG.SMTP.PORT, |
46 | secure: CONFIG.SMTP.TLS, | 46 | secure: CONFIG.SMTP.TLS, |
47 | debug: CONFIG.LOG.LEVEL === 'debug', | ||
48 | logger: bunyanLogger as any, | ||
47 | ignoreTLS: isTestInstance(), | 49 | ignoreTLS: isTestInstance(), |
48 | tls, | 50 | tls, |
49 | auth | 51 | auth |
diff --git a/support/doc/tools.md b/support/doc/tools.md index 144c2bd7a..d83203369 100644 --- a/support/doc/tools.md +++ b/support/doc/tools.md | |||
@@ -11,6 +11,7 @@ | |||
11 | 11 | ||
12 | You need at least 512MB RAM to run the script. | 12 | You need at least 512MB RAM to run the script. |
13 | Scripts can be launched directly from a PeerTube server, or from a separate server, even a desktop PC. | 13 | Scripts can be launched directly from a PeerTube server, or from a separate server, even a desktop PC. |
14 | You need to follow all the following steps even if you are on a PeerTube server. | ||
14 | 15 | ||
15 | ### Dependencies | 16 | ### Dependencies |
16 | 17 | ||
@@ -21,20 +22,20 @@ Install the [PeerTube dependencies](dependencies.md). | |||
21 | Clone the PeerTube repo to get the latest version (even if you are on your PeerTube server): | 22 | Clone the PeerTube repo to get the latest version (even if you are on your PeerTube server): |
22 | 23 | ||
23 | ``` | 24 | ``` |
24 | git clone https://github.com/Chocobozzz/PeerTube.git | 25 | $ git clone https://github.com/Chocobozzz/PeerTube.git |
25 | CLONE="$(pwd)/PeerTube" | 26 | $ CLONE="$(pwd)/PeerTube" |
26 | ``` | 27 | ``` |
27 | 28 | ||
28 | Run ``yarn install`` | 29 | Run ``yarn install`` |
29 | ``` | 30 | ``` |
30 | cd ${CLONE} | 31 | $ cd ${CLONE} |
31 | yarn install | 32 | $ yarn install |
32 | ``` | 33 | ``` |
33 | 34 | ||
34 | Build server tools: | 35 | Build server tools: |
35 | ``` | 36 | ``` |
36 | cd ${CLONE} | 37 | $ cd ${CLONE} |
37 | npm run build:server | 38 | $ npm run build:server |
38 | ``` | 39 | ``` |
39 | 40 | ||
40 | ## Tools | 41 | ## Tools |
@@ -46,8 +47,8 @@ Be sure you own the videos or have the author's authorization to do so. | |||
46 | 47 | ||
47 | 48 | ||
48 | ``` | 49 | ``` |
49 | cd ${CLONE} | 50 | $ cd ${CLONE} |
50 | node dist/server/tools/import-videos.js -u "PEERTUBE_URL" -U "PEERTUBE_USER" --password "PEERTUBE_PASSWORD" -t "TARGET_URL" | 51 | $ node dist/server/tools/import-videos.js -u "PEERTUBE_URL" -U "PEERTUBE_USER" --password "PEERTUBE_PASSWORD" -t "TARGET_URL" |
51 | ``` | 52 | ``` |
52 | 53 | ||
53 | * PEERTUBE_URL : the full URL of your PeerTube server where you want to import, eg: https://peertube.cpy.re/ | 54 | * PEERTUBE_URL : the full URL of your PeerTube server where you want to import, eg: https://peertube.cpy.re/ |
@@ -69,6 +70,6 @@ node dist/server/tools/import-videos.js -u "PEERTUBE_URL" -U "PEERTUBE_USER" --p | |||
69 | You can use this script to import videos directly from the CLI. | 70 | You can use this script to import videos directly from the CLI. |
70 | 71 | ||
71 | ``` | 72 | ``` |
72 | cd ${CLONE} | 73 | $ cd ${CLONE} |
73 | node dist/server/tools/upload.js --help | 74 | $ node dist/server/tools/upload.js --help |
74 | ``` | 75 | ``` |