Skip to content

Commit

Permalink
Updated column names
Browse files Browse the repository at this point in the history
  • Loading branch information
robinsonjohn committed Dec 24, 2024
1 parent eccc2be commit 975b481
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- `Fixed` for any bug fixes.
- `Security` in case of vulnerabilities

## [1.1.0] - 2024.12.24

### Changed

- Updated column names in `PDOHandler`.

## [1.0.1] - 2024.12.23

### Added
Expand Down
10 changes: 5 additions & 5 deletions src/PDOHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ protected function write(LogRecord $record): void
$arr = $record->toArray();

/** @noinspection SqlNoDataSourceInspection */
$sql = "INSERT INTO $this->table_name (channel, level, levelName, message, context, extra, createdAt) VALUES (?,?,?,?,?,?,?)";
$sql = "INSERT INTO $this->table_name (channel, level, level_name, message, context, extra, created_at) VALUES (?,?,?,?,?,?,?)";
$stmt = $this->pdo->prepare($sql);
$stmt->execute([
$record->channel,
Arr::get($arr, 'level'),
Arr::get($arr, 'level_name'),
Arr::get($arr, 'level', 0),
Arr::get($arr, 'level_name', ''),
$record->message,
empty($record->context) ? null : json_encode($record->context),
empty($record->extra) ? null : json_encode($record->extra),
Expand All @@ -57,11 +57,11 @@ public function up(): void
`id` INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
`channel` VARCHAR(255),
`level` INT(3),
`levelName` VARCHAR(10),
`level_name` VARCHAR(10),
`message` TEXT,
`context` JSON,
`extra` JSON,
`createdAt` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP()
`created_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci");

$query->execute();
Expand Down

0 comments on commit 975b481

Please sign in to comment.