[logging] do not overwrite the logger name

Signed-off-by: Jakob Ackermann <das7pad@outlook.com>
This commit is contained in:
Jakob Ackermann 2019-05-02 01:26:35 +02:00
parent 74f26a5fa9
commit a79adcd325

View file

@ -44,10 +44,10 @@ module.exports =
getFileStream: (location, name, opts, _callback = (err, res)->) -> getFileStream: (location, name, opts, _callback = (err, res)->) ->
callback = _.once _callback callback = _.once _callback
filteredName = filterName name filteredName = filterName name
logger.log location:location, name:filteredName, "getting file" logger.log location:location, filteredName:filteredName, "getting file"
sourceStream = fs.createReadStream "#{location}/#{filteredName}", opts sourceStream = fs.createReadStream "#{location}/#{filteredName}", opts
sourceStream.on 'error', (err) -> sourceStream.on 'error', (err) ->
logger.err err:err, location:location, name:name, "Error reading from file" logger.err err:err, location:location, filteredName:name, "Error reading from file"
if err.code == 'ENOENT' if err.code == 'ENOENT'
return callback new Errors.NotFoundError(err.message), null return callback new Errors.NotFoundError(err.message), null
else else
@ -76,10 +76,10 @@ module.exports =
deleteFile: (location, name, callback)-> deleteFile: (location, name, callback)->
filteredName = filterName name filteredName = filterName name
logger.log location:location, name:filteredName, "delete file" logger.log location:location, filteredName:filteredName, "delete file"
fs.unlink "#{location}/#{filteredName}", (err) -> fs.unlink "#{location}/#{filteredName}", (err) ->
if err? if err?
logger.err err:err, location:location, name:filteredName, "Error on delete." logger.err err:err, location:location, filteredName:filteredName, "Error on delete."
callback err callback err
else else
callback() callback()
@ -88,24 +88,24 @@ module.exports =
filteredName = filterName name.replace(/\/$/,'') filteredName = filterName name.replace(/\/$/,'')
rimraf "#{location}/#{filteredName}", (err) -> rimraf "#{location}/#{filteredName}", (err) ->
if err? if err?
logger.err err:err, location:location, name:filteredName, "Error on rimraf rmdir." logger.err err:err, location:location, filteredName:filteredName, "Error on rimraf rmdir."
callback err callback err
else else
callback() callback()
checkIfFileExists:(location, name, callback = (err,exists)->)-> checkIfFileExists:(location, name, callback = (err,exists)->)->
filteredName = filterName name filteredName = filterName name
logger.log location:location, name:filteredName, "checking if file exists" logger.log location:location, filteredName:filteredName, "checking if file exists"
fs.exists "#{location}/#{filteredName}", (exists) -> fs.exists "#{location}/#{filteredName}", (exists) ->
logger.log location:location, name:filteredName, exists:exists, "checked if file exists" logger.log location:location, filteredName:filteredName, exists:exists, "checked if file exists"
callback null, exists callback null, exists
directorySize:(location, name, callback)-> directorySize:(location, name, callback)->
filteredName = filterName name.replace(/\/$/,'') filteredName = filterName name.replace(/\/$/,'')
logger.log location:location, name:filteredName, "get project size in file system" logger.log location:location, filteredName:filteredName, "get project size in file system"
fs.readdir "#{location}/#{filteredName}", (err, files) -> fs.readdir "#{location}/#{filteredName}", (err, files) ->
if err? if err?
logger.err err:err, location:location, name:filteredName, "something went wrong listing prefix in aws" logger.err err:err, location:location, filteredName:filteredName, "something went wrong listing prefix in aws"
return callback(err) return callback(err)
totalSize = 0 totalSize = 0
_.each files, (entry)-> _.each files, (entry)->