Skip to content

Commit 94f5b27

Browse files
committed
Use common log message format
1 parent b700bdb commit 94f5b27

File tree

3 files changed

+6
-2
lines changed

3 files changed

+6
-2
lines changed

LibreNMS/Modules/Core.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
use App\Facades\LibrenmsConfig;
3030
use App\Models\Device;
3131
use App\Models\Eventlog;
32+
use App\Observers\DeviceObserver;
3233
use Illuminate\Support\Facades\Cache;
3334
use Illuminate\Support\Str;
3435
use LibreNMS\Enum\Severity;
@@ -72,7 +73,8 @@ public function discover(OS $os): void
7273

7374
foreach (['sysObjectID', 'sysName', 'sysDescr'] as $attribute) {
7475
if ($device->isDirty($attribute)) {
75-
Eventlog::log($attribute . ': ' . $device->getOriginal($attribute) . ' -> ' . $device->$attribute, $device, 'system', Severity::Notice);
76+
$message = DeviceObserver::attributeChangedMessage($attribute, $device->$attribute, $device->getOriginal($attribute));
77+
Eventlog::log($message, $device, 'system', Severity::Notice);
7678
$os->getDeviceArray()[$attribute] = $device->$attribute; // update device array
7779
}
7880
}

app/Observers/DeviceObserver.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ public function pivotAttached(Device $device, $relationName, $pivotIds, $pivotId
237237
}
238238
}
239239

240-
public static function attributeChangedMessage($attribute, $value, $previous)
240+
public static function attributeChangedMessage($attribute, $value, $previous): string
241241
{
242242
return trans("device.attributes.$attribute") . ': '
243243
. (($previous && $previous != $value) ? "$previous -> " : '')

lang/en/device.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@
1111
'location' => 'Location',
1212
'os' => 'Device OS',
1313
'serial' => 'Serial',
14+
'sysDescr' => 'sysDescr',
1415
'sysName' => 'sysName',
16+
'sysObjectID' => 'sysObjectID',
1517
'version' => 'OS Version',
1618
'type' => 'Device type',
1719
],

0 commit comments

Comments
 (0)