protected function write(array $record) { $hasLevel = in_array($record['level_name'], config('dblogger.levels')); $hasChannel = in_array($record['message'], config('dblogger.channels')); $notifications = config('dblogger.notification'); $send_notification = 0; foreach ($notifications as $key => $value) { if ($key === $record['message']) { $send_notification = in_array($record['level_name'], $value); } } if ($send_notification) { $messages = config('dblogger.messages'); $data = ['record' => $record, 'action' => isset($messages[$record['message']]) ? $messages[$record['message']] : $record['message']]; Mail::send("dblogger::notification", $data, function ($message) { $message->to(config('dblogger.mail_to'))->subject(config('dblogger.mail_subject')); }); } if ($hasLevel && $hasChannel) { if (config('dblogger.service') === 'remote') { $this->post_remote($record); } else { Logger::create(['message' => $record['message'], 'context' => json_encode($record['context']), 'level' => $record['level'], 'level_name' => $record['level_name']]); } } }
public function index(Request $request) { $start_date = $request->get('start_date', null); $end_date = $request->get('end_date', null); $level = $request->get('level', null); $message = $request->get('message', null); $logs = Logger::where(function ($query) use($start_date) { if ($start_date != null) { $query->whereRaw("DATE(created_at) >= DATE('{$start_date}')"); } })->where(function ($query) use($end_date) { if ($end_date != null) { $query->whereRaw("DATE(created_at) <= DATE('{$end_date}')"); } })->where(function ($query) use($level) { if ($level != null) { $query->where("level_name", $level); } })->where(function ($query) use($message) { if ($message != null) { $query->where("message", $message); } })->orderBy('created_at', 'desc')->paginate(100); $messages = config('dblogger.messages'); $levels = config('dblogger.levels'); $channels = config('dblogger.channels'); return view('dblogger-gui::index', compact('logs', 'messages', 'levels', 'level', 'message', 'start_date', 'end_date', 'channels')); }
public function index(Request $request) { Logger::create(['message' => $request->message, 'context' => json_encode($request->data), 'level' => $request->level, 'level_name' => $request->level_name]); return \Response::make(null, 200); }