<?php

class Log extends Vn\Web\JsonRequest {
	const PARAMS = [
		 'message'
		,'file'
		,'line'
		,'location'
		,'agent'
		,'stack'
	];

	function run($db) {	
		if (!_ENABLE_DEBUG) return TRUE;

		$user = isset($_SESSION['user']) ? $_SESSION['user'] : 'guest';
		$message   = $_REQUEST['message'];
		$file      = $_REQUEST['file'];
		$line      = $_REQUEST['line'];
		$location  = $_REQUEST['location'];
		$agent     = $_REQUEST['agent'];
		$stack     = $_REQUEST['stack'];

		error_log(
			 "Javascript: $message in $file($line)"
			."\nLocation: $location"
			."\nAgent: $agent"
			."\nUser: $user"
			."\nStack: $stack"
		);
		return TRUE;
	}
}

