From 6f7e0e5b12c748228f52a6010e0a0891af2b1175 Mon Sep 17 00:00:00 2001 From: Shish Date: Sat, 1 Feb 2020 21:37:07 +0000 Subject: [PATCH] drop logging args that didn't get used in practice --- core/event.php | 3 +-- core/imageboard/image.php | 12 ++++++------ core/logging.php | 24 ++++++++++++------------ core/user.php | 2 +- ext/comment/main.php | 2 +- ext/log_logstash/main.php | 3 +-- ext/numeric_score/main.php | 2 +- ext/report_image/main.php | 2 +- ext/tag_history/main.php | 4 ++-- 9 files changed, 26 insertions(+), 28 deletions(-) diff --git a/core/event.php b/core/event.php index d9986c01..57f9c2dc 100644 --- a/core/event.php +++ b/core/event.php @@ -324,13 +324,12 @@ class LogEvent extends Event */ public $args; - public function __construct(string $section, int $priority, string $message, array $args) + public function __construct(string $section, int $priority, string $message) { parent::__construct(); $this->section = $section; $this->priority = $priority; $this->message = $message; - $this->args = $args; $this->time = time(); } } diff --git a/core/imageboard/image.php b/core/imageboard/image.php index dfd034d8..ca98d13f 100644 --- a/core/imageboard/image.php +++ b/core/imageboard/image.php @@ -360,7 +360,7 @@ class Image SET owner_id=:owner_id WHERE id=:id ", ["owner_id"=>$owner->id, "id"=>$this->id]); - log_info("core_image", "Owner for Image #{$this->id} set to {$owner->name}", null, ["image_id" => $this->id]); + log_info("core_image", "Owner for Image #{$this->id} set to {$owner->name}"); } } @@ -592,7 +592,7 @@ class Image } if ($new_source != $old_source) { $database->execute("UPDATE images SET source=:source WHERE id=:id", ["source"=>$new_source, "id"=>$this->id]); - log_info("core_image", "Source for Image #{$this->id} set to: $new_source (was $old_source)", null, ["image_id" => $this->id]); + log_info("core_image", "Source for Image #{$this->id} set to: $new_source (was $old_source)"); } } @@ -613,7 +613,7 @@ class Image $sln = str_replace('"', "", $sln); if (bool_escape($sln) !== $this->locked) { $database->execute("UPDATE images SET locked=:yn WHERE id=:id", ["yn"=>$sln, "id"=>$this->id]); - log_info("core_image", "Setting Image #{$this->id} lock to: $ln", null, ["image_id" => $this->id]); + log_info("core_image", "Setting Image #{$this->id} lock to: $ln"); } } @@ -732,7 +732,7 @@ class Image ); } - log_info("core_image", "Tags for Image #{$this->id} set to: ".Tag::implode($tags), null, ["image_id" => $this->id]); + log_info("core_image", "Tags for Image #{$this->id} set to: ".Tag::implode($tags)); $cache->delete("image-{$this->id}-tags"); } } @@ -757,7 +757,7 @@ class Image global $database; $this->delete_tags_from_image(); $database->execute("DELETE FROM images WHERE id=:id", ["id"=>$this->id]); - log_info("core_image", 'Deleted Image #'.$this->id.' ('.$this->hash.')', null, ["image_id" => $this->id]); + log_info("core_image", 'Deleted Image #'.$this->id.' ('.$this->hash.')'); unlink($this->get_image_filename()); unlink($this->get_thumb_filename()); @@ -769,7 +769,7 @@ class Image */ public function remove_image_only(): void { - log_info("core_image", 'Removed Image File ('.$this->hash.')', null, ["image_id" => $this->id]); + log_info("core_image", 'Removed Image File ('.$this->hash.')'); @unlink($this->get_image_filename()); @unlink($this->get_thumb_filename()); } diff --git a/core/logging.php b/core/logging.php index 5a9afa1f..da3072a8 100644 --- a/core/logging.php +++ b/core/logging.php @@ -17,10 +17,10 @@ define("SCORE_LOG_NOTSET", 0); * When taking action, a log event should be stored by the server * Quite often, both of these happen at once, hence log_*() having $flash */ -function log_msg(string $section, int $priority, string $message, ?string $flash=null, $args=[]) +function log_msg(string $section, int $priority, string $message, ?string $flash=null) { global $page; - send_event(new LogEvent($section, $priority, $message, $args)); + send_event(new LogEvent($section, $priority, $message)); $threshold = defined("CLI_LOG_LEVEL") ? CLI_LOG_LEVEL : 0; if ((PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg') && ($priority >= $threshold)) { @@ -32,25 +32,25 @@ function log_msg(string $section, int $priority, string $message, ?string $flash } // More shorthand ways of logging -function log_debug(string $section, string $message, ?string $flash=null, $args=[]) +function log_debug(string $section, string $message, ?string $flash=null) { - log_msg($section, SCORE_LOG_DEBUG, $message, $flash, $args); + log_msg($section, SCORE_LOG_DEBUG, $message, $flash); } -function log_info(string $section, string $message, ?string $flash=null, $args=[]) +function log_info(string $section, string $message, ?string $flash=null) { - log_msg($section, SCORE_LOG_INFO, $message, $flash, $args); + log_msg($section, SCORE_LOG_INFO, $message, $flash); } -function log_warning(string $section, string $message, ?string $flash=null, $args=[]) +function log_warning(string $section, string $message, ?string $flash=null) { - log_msg($section, SCORE_LOG_WARNING, $message, $flash, $args); + log_msg($section, SCORE_LOG_WARNING, $message, $flash); } -function log_error(string $section, string $message, ?string $flash=null, $args=[]) +function log_error(string $section, string $message, ?string $flash=null) { - log_msg($section, SCORE_LOG_ERROR, $message, $flash, $args); + log_msg($section, SCORE_LOG_ERROR, $message, $flash); } -function log_critical(string $section, string $message, ?string $flash=null, $args=[]) +function log_critical(string $section, string $message, ?string $flash=null) { - log_msg($section, SCORE_LOG_CRITICAL, $message, $flash, $args); + log_msg($section, SCORE_LOG_CRITICAL, $message, $flash); } diff --git a/core/user.php b/core/user.php index 4f79e908..56b57471 100644 --- a/core/user.php +++ b/core/user.php @@ -121,7 +121,7 @@ class User if (!$my_user && strpos($name, " ") !== false) { $my_user = User::by_name(str_replace(" ", "_", $name)); } - + if ($my_user) { if ($my_user->passhash == md5(strtolower($name) . $pass)) { log_info("core-user", "Migrating from md5 to bcrypt for $name"); diff --git a/ext/comment/main.php b/ext/comment/main.php index 51a8f819..a442e4e4 100644 --- a/ext/comment/main.php +++ b/ext/comment/main.php @@ -625,7 +625,7 @@ class CommentList extends Extension $snippet = substr($comment, 0, 100); $snippet = str_replace("\n", " ", $snippet); $snippet = str_replace("\r", " ", $snippet); - log_info("comment", "Comment #$cid added to Image #$image_id: $snippet", null, ["image_id"=>$image_id, "comment_id"=>$cid]); + log_info("comment", "Comment #$cid added to Image #$image_id: $snippet"); } private function comment_checks(int $image_id, User $user, string $comment) diff --git a/ext/log_logstash/main.php b/ext/log_logstash/main.php index 25340a34..74edf13b 100644 --- a/ext/log_logstash/main.php +++ b/ext/log_logstash/main.php @@ -15,7 +15,6 @@ class LogLogstash extends Extension "section" => $event->section, "priority" => $event->priority, "time" => $event->time, - "args" => $event->args, ], #"@request" => $_SERVER, "@request" => [ @@ -42,7 +41,7 @@ class LogLogstash extends Extension try { $parts = explode(":", $host); $host = $parts[0]; - $port = $parts[1]; + $port = (int)$parts[1]; $fp = fsockopen("udp://$host", $port, $errno, $errstr); if (! $fp) { return; diff --git a/ext/numeric_score/main.php b/ext/numeric_score/main.php index 0f9449c0..2592388a 100644 --- a/ext/numeric_score/main.php +++ b/ext/numeric_score/main.php @@ -159,7 +159,7 @@ class NumericScore extends Extension public function onNumericScoreSet(NumericScoreSetEvent $event) { global $user; - log_debug("numeric_score", "Rated Image #{$event->image_id} as {$event->score}", "Rated Image", ["image_id"=>$event->image_id]); + log_debug("numeric_score", "Rated Image #{$event->image_id} as {$event->score}", "Rated Image"); $this->add_vote($event->image_id, $user->id, $event->score); } diff --git a/ext/report_image/main.php b/ext/report_image/main.php index 4d23d679..ca406ec2 100644 --- a/ext/report_image/main.php +++ b/ext/report_image/main.php @@ -83,7 +83,7 @@ class ReportImage extends Extension public function onAddReportedImage(AddReportedImageEvent $event) { global $cache, $database; - log_info("report_image", "Adding report of Image #{$event->report->image_id} with reason '{$event->report->reason}'", null, ["image_id" => $event->report->image_id]); + log_info("report_image", "Adding report of Image #{$event->report->image_id} with reason '{$event->report->reason}'"); $database->Execute( "INSERT INTO image_reports(image_id, reporter_id, reason) VALUES (:image_id, :reporter_id, :reason)", diff --git a/ext/tag_history/main.php b/ext/tag_history/main.php index 57a4ca9c..e0468119 100644 --- a/ext/tag_history/main.php +++ b/ext/tag_history/main.php @@ -353,9 +353,9 @@ class TagHistory extends Extension if (empty($old_tags)) { /* no old tags, so we are probably adding the image for the first time */ - log_debug("tag_history", "adding new tag history: [$new_tags]", null, ["image_id" => $image->id]); + log_debug("tag_history", "adding new tag history: [$new_tags]"); } else { - log_debug("tag_history", "adding tag history: [$old_tags] -> [$new_tags]", null, ["image_id" => $image->id]); + log_debug("tag_history", "adding tag history: [$old_tags] -> [$new_tags]"); } $allowed = $config->get_int("history_limit");