. * * @package LibreNMS * @link http://librenms.org * @copyright 2019 Tony Murray * @author Tony Murray */ namespace App\Facades; use Auth; class LogManager extends \Illuminate\Log\LogManager { /** * Log events to the event table * * @param string $text message describing the event * @param \App\Models\Device|int $device device array or device_id * @param string $type brief category for this event. Examples: sensor, state, stp, system, temperature, interface * @param int $severity 1: ok, 2: info, 3: notice, 4: warning, 5: critical, 0: unknown * @param int $reference the id of the referenced entity. Supported types: interface */ public function event($text, $device = null, $type = null, $severity = 2, $reference = null) { (new \App\Models\Eventlog([ 'device_id' => $device instanceof \App\Models\Device ? $device->device_id : $device, 'reference' => $reference, 'type' => $type, 'datetime' => \Carbon\Carbon::now(), 'severity' => $severity, 'message' => $text, 'username' => Auth::user() ? Auth::user()->username : '', ]))->save(); } }