// LoggingMiddleware.php Logger::access(); // TenantService.php — after creating a tenant Logger::event('tenant.created', $tenant->toArray()); // OrderService.php — when an order is placed Logger::event('order.placed', [ 'order_id' => $order->id, 'tenant_id' => $order->tenant_id, 'total' => $order->total, ]); // UserService.php — track what changed Logger::audit('user.updated', $userId, [ 'before' => ['plan' => 'free'], 'after' => ['plan' => 'pro'], ]); // PaymentService.php Logger::payment('charge.success', [ 'reference' => $ref, 'amount' => $amount, 'currency' => 'NGN', 'gateway' => 'paystack', ]); // DBConnect.php — on PDO exception Logger::error('error', [ 'message' => $e->getMessage(), 'query' => $sql, ]); // {"timestamp":"2026-05-12 14:00:00","level":"INFO","channel":"event","data":{"event":"order.placed","payload":{"order_id":1042,"total":28800}}} // {"timestamp":"2026-05-12 14:01:22","level":"INFO","channel":"payment","data":{"event":"charge.success","data":{"reference":"PSK_xyz","amount":28800}}} // {"timestamp":"2026-05-12 14:03:10","level":"ERROR","channel":"error","data":{"message":"SQLSTATE...","query":"INSERT INTO..."}}} // plugs directly into Logger Logger::error('error', JsonBuilder::init() ::raw([ 'what' => $e->getMessage(), 'where' => $e->getFile() . ':' . $e->getLine(), 'when' => AppDateTime::now(), 'why' => 'Unexpected exception in TenantService', ]) ::build() )