/** * Converts the logging event into an array which can be logged to mongodb. * * @param Ideasa_Log4php_LoggerLoggingEvent $event * @return array The array representation of the logging event. */ protected function format(Ideasa_Log4php_LoggerLoggingEvent $event) { $timestampSec = (int) $event->getTimestamp(); $timestampUsec = (int) (($event->getTimestamp() - $timestampSec) * 1000000); $document = array('timestamp' => new MongoDate($timestampSec, $timestampUsec), 'level' => $event->getLevel()->toString(), 'thread' => (int) $event->getThreadName(), 'message' => $event->getMessage(), 'loggerName' => $event->getLoggerName()); $locationInfo = $event->getLocationInformation(); if ($locationInfo != null) { $document['fileName'] = $locationInfo->getFileName(); $document['method'] = $locationInfo->getMethodName(); $document['lineNumber'] = $locationInfo->getLineNumber() == 'NA' ? 'NA' : (int) $locationInfo->getLineNumber(); $document['className'] = $locationInfo->getClassName(); } $throwableInfo = $event->getThrowableInformation(); if ($throwableInfo != null) { $document['exception'] = $this->formatThrowable($throwableInfo->getThrowable()); } return $document; }