module.exports = (function () {
	'use strict';

	function SGSServerErrorLogger (config, saveCallback, sendCallback) {
		if (sendCallback === undefined) {
			saveCallback = config;
			sendCallback = saveCallback;
			config = {};
		}

		config = config || {};

		this.save = saveCallback || function () {};

		this.send = sendCallback;

		return this.middleware.bind(this);
	}

	SGSServerErrorLogger.prototype.middleware = function (error, req, res, next) {
		if (!(error instanceof Error)) {
			error = new Error(error);
		}

		this.save({
			pid: process.pid,
			reqId: req.data.id,
			name: error.name,
			stack: error.stack,
			message: error.message
		});

		if (this.send === undefined) {
			return res.status(500).json({
				error: {
					id: req.data.id,
					code: error.code,
					status: 500
				}
			});
		}

		this.send(error, req, res, next);
	};

	return SGSServerErrorLogger;

})();

@@ -155,34 +155,8 @@
 %09%09%09s
-aveCallback = config;%0A%09%09%09s
 endC
@@ -177,16 +177,42 @@
 Callback
+;%0A%09%09%09saveCallback = config
 ;%0A%09%09%09con
@@ -699,16 +699,21 @@
 turn res
+%0A%09%09%09%09
 .status(
@@ -720,16 +720,21 @@
 500)
+%0A%09%09%09%09
 .json(%7B%0A
 %09%09%09%09
@@ -729,16 +729,17 @@
 .json(%7B%0A
+%09
 %09%09%09%09erro
@@ -743,16 +743,17 @@
 rror: %7B%0A
+%09
 %09%09%09%09%09id:
@@ -771,16 +771,17 @@
 d,%0A%09%09%09%09%09
+%09
 code: er
@@ -795,16 +795,17 @@
 e,%0A%09%09%09%09%09
+%09
 status: 
@@ -812,18 +812,20 @@
 500%0A%09%09%09%09
+%09
 %7D%0A
+%09
 %09%09%09%7D);%0A%09

Send calback is now set correctly when underloading arguments.g