mirror of
https://github.com/jupyterhub/jupyterhub.git
synced 2025-10-13 04:53:01 +00:00
use loglevel for js logging
because javascript is the best!
This commit is contained in:
@@ -5,7 +5,8 @@
|
||||
//
|
||||
|
||||
var http = require('http'),
|
||||
httpProxy = require('http-proxy');
|
||||
httpProxy = require('http-proxy'),
|
||||
log = require('loglevel');
|
||||
|
||||
var bound = function (that, method) {
|
||||
// bind a method, to ensure `this=that` when it is called
|
||||
@@ -92,7 +93,7 @@ var ConfigurableProxy = function (options) {
|
||||
try {
|
||||
return handler.apply(that, arguments);
|
||||
} catch (e) {
|
||||
console.log("Error in handler for " +
|
||||
log.error("Error in handler for " +
|
||||
req.method + ' ' + req.url + ': ', e
|
||||
);
|
||||
}
|
||||
@@ -111,7 +112,7 @@ var ConfigurableProxy = function (options) {
|
||||
|
||||
ConfigurableProxy.prototype.fail = function (req, res, code, msg) {
|
||||
msg = msg || '';
|
||||
console.log('[' + code + '] ' + req.method + ' ' + req.url + ': ' + msg);
|
||||
log.error('[' + code + '] ' + req.method + ' ' + req.url + ': ' + msg);
|
||||
res.writeHead(code);
|
||||
res.write(msg);
|
||||
res.end();
|
||||
@@ -136,7 +137,7 @@ ConfigurableProxy.prototype.get_routes = function (req, res) {
|
||||
|
||||
ConfigurableProxy.prototype.post_routes = function (req, res, path, data) {
|
||||
// POST adds a new route
|
||||
console.log('POST', path, data);
|
||||
log.debug('POST', path, data);
|
||||
|
||||
// ensure path starts with /
|
||||
if (path[0] != '/') {
|
||||
@@ -153,7 +154,7 @@ ConfigurableProxy.prototype.post_routes = function (req, res, path, data) {
|
||||
|
||||
ConfigurableProxy.prototype.delete_routes = function (req, res, path) {
|
||||
// DELETE removes an existing route
|
||||
console.log('DELETE', path);
|
||||
log.debug('DELETE', path);
|
||||
if (this.routes[path] === undefined) {
|
||||
res.writeHead(404);
|
||||
} else {
|
||||
@@ -193,11 +194,11 @@ ConfigurableProxy.prototype.target_for_url = function (url) {
|
||||
ConfigurableProxy.prototype.handle_ws = function (req, res, head) {
|
||||
// no local route found, time to proxy
|
||||
var target = this.target_for_url(req.url);
|
||||
console.log("PROXY WS " + req.url + " to " + target);
|
||||
log.debug("PROXY WS " + req.url + " to " + target);
|
||||
this.proxy.ws(req, res, head, {
|
||||
target: target
|
||||
}, function (e) {
|
||||
console.log("Proxy error: ", e);
|
||||
log.error("Proxy error: ", e);
|
||||
res.writeHead(502);
|
||||
res.write("Proxy target missing");
|
||||
res.end();
|
||||
@@ -206,11 +207,11 @@ ConfigurableProxy.prototype.handle_ws = function (req, res, head) {
|
||||
|
||||
ConfigurableProxy.prototype.handle_proxy_request = function (req, res) {
|
||||
var target = this.target_for_url(req.url);
|
||||
console.log("PROXY " + req.method + " " + req.url + " to " + target);
|
||||
log.debug("PROXY " + req.method + " " + req.url + " to " + target);
|
||||
this.proxy.web(req, res, {
|
||||
target: target
|
||||
}, function (e) {
|
||||
console.log("Proxy error: ", e);
|
||||
log.error("Proxy error: ", e);
|
||||
res.writeHead(502);
|
||||
res.write("Proxy target missing");
|
||||
res.end();
|
||||
|
Reference in New Issue
Block a user