How to use the log4js.error function in log4js

To help you get started, we’ve selected a few log4js examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github joewhite86 / proxy-rotator / app.js View on Github external
return function (err) {
    proxy.inUse = false
    // handle timeout as Broken proxy
    if(BlockErrors.indexOf(err.code) !== -1) {
      if(!proxy.broken) {
        proxy.broken = new Date()
        proxy.errors++
        logger.warn('added ' + proxy.proxy + ' to broken list for host ' + url.host + ' (' + err.code + ')')
        if(Proxies.allBroken()) {
          logger.error('all proxies are broken')
        }
      }
    }
    else {
      logger.error(err)
    }
  }
}
github joewhite86 / proxy-rotator / app.js View on Github external
return function (err) {
    proxy.inUse = false
    // handle timeout as Broken proxy
    if(BlockErrors.indexOf(err.code) !== -1) {
      if(!proxy.broken) {
        proxy.broken = new Date()
        proxy.errors++
        logger.warn('added ' + proxy.proxy + ' to broken list for host ' + url.host + ' (' + err.code + ')')
        if(Proxies.allBroken()) {
          logger.error('all proxies are broken')
        }
      }
    }
    else {
      logger.error(err)
    }
  }
}
github joewhite86 / proxy-rotator / app.js View on Github external
return function (err, response, body) {
    proxy.inUse = false
    if(GraceTime !== 0) proxy.lastRequest = new Date()
    if(err) {
      res.writeHead(500, {
        'Content-Length': err.message? err.message.length: 0,
        'Content-Type': 'text/plain',
        'x-proxy': proxy.proxy
      })
      res.status(500).end(err.message || '')
      return
    } else if(response.statusCode === 403) {
      logger.error(proxy.proxy + ' is blocked')
      proxy.blocked = new Date()
      if(Proxies.allBlocked()) {
        logger.error('all proxies are blocked')
      }
      return setTimeout(function() {
        handleRequest(req, res)
      }, NextReqTimeout)
    }
    var header = response.headers
    proxy.hits++
    header['x-proxy'] = proxy.proxy
    res.writeHead(response.statusCode, header)
    res.end(body)
  }
}
github joewhite86 / proxy-rotator / app.js View on Github external
return function (err, response, body) {
    proxy.inUse = false
    if(GraceTime !== 0) proxy.lastRequest = new Date()
    if(err) {
      res.writeHead(500, {
        'Content-Length': err.message? err.message.length: 0,
        'Content-Type': 'text/plain',
        'x-proxy': proxy.proxy
      })
      res.status(500).end(err.message || '')
      return
    } else if(response.statusCode === 403) {
      logger.error(proxy.proxy + ' is blocked')
      proxy.blocked = new Date()
      if(Proxies.allBlocked()) {
        logger.error('all proxies are blocked')
      }
      return setTimeout(function() {
        handleRequest(req, res)
      }, NextReqTimeout)
    }
    var header = response.headers
    proxy.hits++
    header['x-proxy'] = proxy.proxy
    res.writeHead(response.statusCode, header)
    res.end(body)
  }
}