Comment créer un fichier log en php/phpmysql ? (slimframework)
Bonjour,
je voulais savoir comment faire pour comment créer un fichier log en php pour enregistrer les informations nécessaires (date, adresse IP ...etc) sur celui qui a fait un appel a une méthode d'API (en slimframework)?
Par exemple: un fichier log pour voir qui a fait appel à la méthode "books"?
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
| $app->get('/books',
function ($request, $response, $args)
{
try {
$db = DB();
$stmt = $db->query("SELECT * from books");
$items = $stmt->fetchAll(PDO::FETCH_OBJ);
$stmt = null;
// création du fichier log pour savoir qui a exécuter cette requête!
}
catch(PDOException $e) {
die("ERROR: " . $e->getMessage());
}
return json_encode($items, JSON_UNESCAPED_UNICODE);
}); |