Ideally you would use the builtin Log system provided by Laravel and extend it as needed. The underlying service is Monolog and it is extendable and documented on Monologs site. You can use a model similar to what you've setup or access MySQL directly. All you really need to do is create your own custom handler. See the links below to get started. However, if you really want to create a "global" function then you should register the service in your app, you can reference the Service Provider link from the documentation below.
Docs on logging and errors: https://laravel.com/docs/5.2/errors
Useful starter for setting up your own custom log handler in Monolog: https://github.com/waza-ari/monolog-mysql/blob/master/src/MySQLHandler/MySQLHandler.php
Custom Service Providers: https://laravel.com/docs/5.2/providers
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community