drop logging args that didn't get used in practice

This commit is contained in:
Shish 2020-02-01 21:37:07 +00:00
parent 3f689b68bc
commit 6f7e0e5b12
9 changed files with 26 additions and 28 deletions

View File

@ -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();
}
}

View File

@ -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());
}

View File

@ -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);
}

View File

@ -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");

View File

@ -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)

View File

@ -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;

View File

@ -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);
}

View File

@ -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)",

View File

@ -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");