--- functions.php.orig	2016-04-26 19:31:31.893762032 +0000
+++ functions.php	2016-06-29 08:52:28.895708884 +0000
@@ -5276,3 +5276,66 @@
 	// Strip timezone information
 	return preg_replace( '/(?:Z|[+-]\d{2}(?::\d{2})?)$/', '', $formatted );
 }
+
+/**
+ *
+ * Send debug messages to default log or die on critical errors
+ *
+ * Every message sent with priority >= 3 ( LOG_ERR ) will trigger and immediate
+ * wp_die and display the error.
+ *
+ * All levels below this will be sent via error_log.
+ *
+ * The output level can be controlled by WP_DEBUG_LEVEL constant.
+ *
+ * @param string $message
+ * @param int $level
+ *
+ * @output log to syslog | wp_die on high level
+ * @return false on not taking action, true on log sent
+ */
+function wp_debug( $message, $level = LOG_NOTICE ) {
+	if ( empty( $message ) )
+		return false;
+
+	if ( @is_array( $message ) || @is_object ( $message ) )
+		$message = json_encode( $message );
+
+	$levels = array (
+		LOG_EMERG => 0,   // Emergency     system is unusable
+		LOG_ALERT => 1,   // Alert         action must be taken immediately
+		LOG_CRIT => 2,    // Critical      critical conditions
+		LOG_ERR => 3,     // Error         error conditions
+		LOG_WARNING => 4, // Warning       warning conditions
+		LOG_NOTICE => 5,  // Notice        normal but significant condition
+		LOG_INFO => 6,    // Informational informational messages
+		LOG_DEBUG => 7,   // Debug         debug-level messages
+	);
+
+	// number for number based comparison
+	// should work with the defines only, this is just a make-it-sure step
+	$level = $levels [ $level ];
+
+	// in case WordPress debug log has a minimum level
+	if ( defined ( 'WP_DEBUG_LEVEL' ) ) {
+		$wp_level = $levels [ WP_DEBUG_LEVEL ];
+		if ( $level > $wp_level ) {
+			return false;
+		}
+	}
+
+	// ERR, CRIT, ALERT and EMERG
+	if ( 3 >= $level ) {
+		wp_die( '<h1>Error:</h1>' . '<p>' . $message . '</p>' );
+		exit;
+	}
+
+	$trace = debug_backtrace();
+	$caller = $trace[1];
+	$parent = $caller['function'];
+
+	if (isset($caller['class']))
+		$parent = $caller['class'] . '::' . $parent;
+
+	return error_log( "{$parent}: {$message}" );
+}
\ No newline at end of file
