-1

I'm using Laravel 5.7 and know about the Monolog package.

My question now is, since I haven't found a proper tutorial on correctly logging your data, how do I properly log if the user input, converted into an array, is sent to the database?

The array is quite big, so I don't see any use in logging this whole thing, but I want to make sure the array has been passed to the database(using API package for the db connection and the methods to save the data).

Any idea how I can log if the data was sent correctly? (and of course log it, when something went wrong)

ofmiceandmoon
  • 548
  • 2
  • 9
  • 30

2 Answers2

0

You could use DB::listen inside a provider, like the docs suggest. https://laravel.com/docs/5.7/database#listening-for-query-events

This would log every query done to your database but what you should use to ensure the data sent by an user is correct is validation, probably in the form of Form Requests. https://laravel.com/docs/5.7/validation#form-request-validation

IGP
  • 14,160
  • 4
  • 26
  • 43
  • The Database I'm talking about is FileMaker, so I don't think this would work. And I'm using Form Requests, but I just want to be sure if it worked correctly. – ofmiceandmoon Dec 05 '19 at 13:09
  • Googling reveals a package to add a driver for FileMaker. (https://github.com/andreossido/laravel-filemaker) which depends on laravel-odbc (https://github.com/andreossido/laravel-odbc). Perhaps using those, you may use the DB facade to listen in on queries. – IGP Dec 05 '19 at 13:35
0

If you using on local install, try to get the telescope package. This package installs a logger ambient with a good approach not only in database, but, in a series of points inside laravel.

William Prigol Lopes
  • 1,803
  • 14
  • 31