Skip to content

Commit c7f0b52

Browse files
refactor: deprecate old log_error method
1 parent 747d61b commit c7f0b52

7 files changed

Lines changed: 11 additions & 19 deletions

File tree

pfSense-pkg-RESTAPI/files/usr/local/pkg/RESTAPI/Core/BaseTraits.inc

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -66,13 +66,4 @@ trait BaseTraits {
6666
syslog(priority: $level, message: $message);
6767
closelog();
6868
}
69-
70-
/**
71-
* Logs an error to the syslog.
72-
* @param string $message The error message to write to the syslog
73-
*/
74-
public static function log_error(string $message): void {
75-
# Call the pfSense `log_error` function
76-
log_error($message);
77-
}
7869
}

pfSense-pkg-RESTAPI/files/usr/local/pkg/RESTAPI/Models/CertificateAuthorityRenew.inc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ class CertificateAuthorityRenew extends Model {
120120
# Otherwise, continue with the renewal
121121
$this->newserial->value = cert_get_serial($ca_config['item']['crt']);
122122
$msg = "Renewed CA {$ca_config['item']['descr']} ({$ca_config['item']['refid']}) - Serial {$this->oldserial->value} -> {$this->newserial->value}";
123-
$this->log_error($msg);
123+
$this->log(level: LOG_ERR, message: $msg, logfile: "system");
124124
$this->write_config($msg);
125125
}
126126

pfSense-pkg-RESTAPI/files/usr/local/pkg/RESTAPI/Models/CertificateRenew.inc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ class CertificateRenew extends Model {
120120
# Otherwise, continue with the renewal
121121
$this->newserial->value = cert_get_serial($cert_config['item']['crt']);
122122
$msg = "Renewed certificate {$cert_config['item']['descr']} ({$cert_config['item']['refid']}) - Serial {$this->oldserial->value} -> {$this->newserial->value}";
123-
$this->log_error($msg);
123+
$this->log(level: LOG_ERR, message: $msg, logfile: "system");
124124
$this->write_config($msg);
125125
}
126126

pfSense-pkg-RESTAPI/files/usr/local/pkg/RESTAPI/Models/RESTAPIAccessListEntry.inc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,8 @@ class RESTAPIAccessListEntry extends Model {
137137

138138
# If the assigned schedule no longer exists, log the event and deny access
139139
if (!$this->sched->get_related_model()) {
140-
$this->log_error(
140+
$this->log(
141+
level: LOG_ERR,
141142
message: "The schedule '{$this->sched->value}' assigned to REST API access list entry " .
142143
"'$this->id' no longer exists.",
143144
);

pfSense-pkg-RESTAPI/files/usr/local/pkg/RESTAPI/Models/RESTAPISettingsSync.inc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,13 +122,13 @@ class RESTAPISettingsSync extends Model {
122122
# Log an error if the HTTP failed
123123
if (!$response) {
124124
cprint(message: 'failed.' . PHP_EOL, condition: $print_status);
125-
self::log_error("Failed to sync REST API settings to $ha_sync_host: no response received.");
125+
self::log(level: LOG_ERR, message: "Failed to sync REST API settings to $ha_sync_host: no response received.");
126126
} elseif (!$response_json) {
127127
cprint(message: 'failed.' . PHP_EOL, condition: $print_status);
128-
self::log_error("Failed to sync REST API settings to $ha_sync_host: received unexpected response.");
128+
self::log(level: LOG_ERR, message: "Failed to sync REST API settings to $ha_sync_host: received unexpected response.");
129129
} elseif ($response_json['code'] !== 200) {
130130
cprint(message: 'failed.' . PHP_EOL, condition: $print_status);
131-
self::log_error("Failed to sync REST API settings to $ha_sync_host: {$response_json['message']}");
131+
self::log(level: LOG_ERR, message: "Failed to sync REST API settings to $ha_sync_host: {$response_json['message']}");
132132
} else {
133133
cprint(message: 'done.' . PHP_EOL, condition: $print_status);
134134
}

pfSense-pkg-RESTAPI/files/usr/local/pkg/RESTAPI/Models/RESTAPIVersion.inc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -236,8 +236,8 @@ class RESTAPIVersion extends Model {
236236

237237
# If an error occurred either deleting or adding the package, return false
238238
if ($delete->result_code !== 0 or $add->result_code !== 0) {
239-
$this->log_error($delete->output);
240-
$this->log_error($add->output);
239+
$this->log(level: LOG_ERR, message: $delete->output);
240+
$this->log(level: LOG_ERR, message: $add->output);
241241
return false;
242242
}
243243

pfSense-pkg-RESTAPI/files/usr/local/pkg/RESTAPI/Models/SSH.inc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,11 @@ class SSH extends Model {
5656
public function apply() {
5757
# Stop the sshd service
5858
killbyname('sshd');
59-
$this->log_error('secure shell configuration has changed. Stopping sshd.');
59+
$this->log(level: LOG_ERR, message: 'secure shell configuration has changed. Stopping sshd.', logfile: "system");
6060

6161
# If sshd is still enabled, restart the sshd service using the new config
6262
if (config_path_enabled('system/ssh', 'enable')) {
63-
$this->log_error('secure shell configuration has changed. Restarting sshd.');
63+
$this->log(level: LOG_ERR, message: 'secure shell configuration has changed. Restarting sshd.', logfile: "system");
6464
send_event('service restart sshd');
6565
}
6666
}

0 commit comments

Comments
 (0)