]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/commitdiff
Logging refractoring
authorChocobozzz <florian.bigard@gmail.com>
Sun, 6 Dec 2015 20:36:57 +0000 (21:36 +0100)
committerChocobozzz <florian.bigard@gmail.com>
Mon, 7 Dec 2015 16:22:36 +0000 (17:22 +0100)
middlewares/misc.js
middlewares/reqValidators/remote.js
src/pods.js
src/poolRequests.js
src/utils.js

index 69e8d78c1ada78fda2d318a68f28a48ba7bd605f..9755eeff064a02de64993af9616112c49f8679d4 100644 (file)
   }
 
   misc.decryptBody = function (req, res, next) {
-    logger.debug('Decrypting body.')
-
     PodsDB.findOne({ url: req.body.signature.url }, function (err, pod) {
       if (err) {
         logger.error('Cannot get signed url in decryptBody.', { error: err })
         res.sendStatus(500)
       }
 
-      logger.debug('Found one pod which could send the message.', { pod: pod.publicKey, url: req.body.signature.url })
+      logger.debug('Decrypting body from %s.', req.body.signature.url)
 
       var crt = ursa.createPublicKey(pod.publicKey)
       var signature_ok = crt.hashAndVerify('sha256', new Buffer(req.body.signature.url).toString('hex'), req.body.signature.signature, 'hex')
@@ -41,9 +39,8 @@
       if (signature_ok === true) {
         var myKey = ursa.createPrivateKey(fs.readFileSync(utils.certDir + 'peertube.key.pem'))
         var decryptedKey = myKey.decrypt(req.body.key, 'hex', 'utf8')
-        logger.debug(decryptedKey)
         req.body.data = JSON.parse(utils.symetricDecrypt(req.body.data, decryptedKey))
-        logger.debug('Decrypted.', { body: req.body })
+        delete req.body.key
       } else {
         logger.error('Signature is not okay in decryptBody for %s.', req.body.signature.url)
         res.sendStatus(500)
index 642dad1c777bdee003ea2871493f97f284007495..a9d2cdf20e478f3f9e93408964def279ba4c0c8e 100644 (file)
@@ -12,7 +12,7 @@
     req.checkBody('key', 'Should have a key').notEmpty()
     req.checkBody('data', 'Should have data').notEmpty()
 
-    logger.debug('Checking secureRequest parameters', { parameters: req.body })
+    logger.debug('Checking secureRequest parameters', { parameters: { data: req.body.data, keyLength: req.body.key.length } })
 
     checkErrors(req, res, next)
   }
index 9afc6cc96cce7d27f396d61d693293db84d98f4a..a0dbb6b68c2efeff289b3f0f9aed2a7959005114 100644 (file)
@@ -97,7 +97,6 @@
         var pods_list = computeWinningPods(urls, pods_score)
         logger.debug('Pods that we keep computed.', { pods_to_keep: pods_list })
 
-        logger.debug('Make requests...')
         makeRequestsToWinningPods(cert, pods_list)
       })
     })
index ee6c0156e2e8aa3eafc30d08080093a03319e4c4..391ed6ab2b2544bbb495f0821a7f895032357413 100644 (file)
@@ -74,7 +74,6 @@
   }
 
   function makePoolRequest (type, requests) {
-    logger.debug('Make pool requests scheduled.')
     PodsDB.find({}, { _id: 1, url: 1, publicKey: 1 }).exec(function (err, pods) {
       if (err) throw err
 
index 4aa1fc55e1da6397c475e0d3b6ee5a38946efbf7..30edcd0e9db5601a46f72166142e7f196f75a1f3 100644 (file)
@@ -30,7 +30,7 @@
       }
     }
 
-    logger.debug('Sending informations to %s.', to_pod.url, { params: params })
+    logger.debug('Make retry requests to %s.', to_pod.url)
     // Default 10 but in tests we want to be faster
     var retries = utils.isTestInstance() ? 2 : 10
 
@@ -84,8 +84,6 @@
 
       // Add data with POST requst ?
       if (all_data.method === 'POST' && all_data.data) {
-        logger.debug('Make a POST request.')
-
         // Encrypt data ?
         if (all_data.encrypt === true) {
           var crt = ursa.createPublicKey(pod.publicKey)
           makeRetryRequest(params, url, pod, signature, callbackEachRetryRequest)
         }
       } else {
-        logger.debug('Make a GET/DELETE request')
         makeRetryRequest(params, url, pod, signature, callbackEachRetryRequest)
       }
     }, callback)