Skip to content

Instantly share code, notes, and snippets.

@graceman9
Created August 13, 2020 12:11
Show Gist options
  • Save graceman9/e4ac52f9c6da2ade877ac337fa2879b2 to your computer and use it in GitHub Desktop.
Save graceman9/e4ac52f9c6da2ade877ac337fa2879b2 to your computer and use it in GitHub Desktop.
<?php
/**
* @file
*
* Very simple logger, log to console.log().
*/
namespace App;
class Logger {
public static function log($response) {
if (is_object($response) || is_array($response)) {
$response = json_encode($response);
echo '<script>console.log(JSON.parse(\'' . $response . '\'));</script>';
}
else {
echo '<script>console.log(\'' . $response . '\');</script>';
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment