summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'CheckUser/src/EventLogger.php')
-rw-r--r--CheckUser/src/EventLogger.php45
1 files changed, 45 insertions, 0 deletions
diff --git a/CheckUser/src/EventLogger.php b/CheckUser/src/EventLogger.php
new file mode 100644
index 00000000..d94d9855
--- /dev/null
+++ b/CheckUser/src/EventLogger.php
@@ -0,0 +1,45 @@
+<?php
+
+namespace MediaWiki\CheckUser;
+
+use EventLogging;
+use ExtensionRegistry;
+
+class EventLogger {
+ /** @var ExtensionRegistry */
+ private $extensionRegistry;
+
+ /**
+ * @param ExtensionRegistry $extensionRegistry
+ */
+ public function __construct(
+ ExtensionRegistry $extensionRegistry
+ ) {
+ $this->extensionRegistry = $extensionRegistry;
+ }
+
+ /**
+ * Log an event using the SpecialInvestigate schema.
+ *
+ * @param array $event
+ */
+ public function logEvent( $event ) : void {
+ if ( $this->extensionRegistry->isLoaded( 'EventLogging' ) ) {
+ EventLogging::logEvent(
+ 'SpecialInvestigate',
+ // Revision ID of the schema - keep this in sync with extension.json
+ 20261100,
+ $event
+ );
+ }
+ }
+
+ /**
+ * Get a timestamp in milliseconds.
+ *
+ * @return int
+ */
+ public function getTime() : int {
+ return (int)round( microtime( true ) * 1000 );
+ }
+}