Skip to content

Commit 652e52c

Browse files
committed
🏷️v1.1.2 🛠️ bugfix in config logic, fixed readme example. Gotta go: 🍼👶
1 parent 6e20430 commit 652e52c

File tree

3 files changed

+32
-11
lines changed

3 files changed

+32
-11
lines changed

readme.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,8 +178,8 @@ Or based on date (most be valid date/datetime supported by strtotime())
178178
http://php.net/manual/en/function.strtotime.php
179179

180180
```php
181-
LogToDB::removeOlderThen('2019-01-01');
182-
LogToDB::removeOlderThen('2019-01-01 23:00:00');
181+
LogToDB::model()->removeOlderThen('2019-01-01');
182+
LogToDB::model()->removeOlderThen('2019-01-01 23:00:00');
183183
```
184184

185185
##### Advanced /config/logging.php example

src/LogToDB.php

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,19 @@ class LogToDB
5959
/**
6060
* LogToDB constructor.
6161
*
62-
* @param null $channelConnection
63-
* @param null $collection
64-
* @param null $detailed
65-
* @param null $maxRows
62+
* @param string|null $channelConnection
63+
* @param string|null $collection
64+
* @param bool|null $detailed
65+
* @param bool|null $queue
66+
* @param string|null $queueName
67+
* @param string|null $queueConnection
6668
*/
67-
function __construct($channelConnection = null, $collection = null, $detailed = null, $maxRows = null)
69+
function __construct(string $channelConnection = null,
70+
string $collection = null,
71+
bool $detailed = null,
72+
bool $queue = null,
73+
string $queueName = null,
74+
string $queueConnection = null)
6875
{
6976
//Log default config if present
7077
$config = config('logtodb');
@@ -102,8 +109,14 @@ function __construct($channelConnection = null, $collection = null, $detailed =
102109
if (!empty($detailed)) {
103110
$this->detailed = $detailed;
104111
}
105-
if (!empty($maxRows)) {
106-
$this->maxRows = (int)$maxRows;
112+
if (!empty($queue)) {
113+
$this->saveWithQueue = $queue;
114+
}
115+
if (!empty($queueName)) {
116+
$this->saveWithQueueName = $queueName;
117+
}
118+
if (!empty($queueConnection)) {
119+
$this->saveWithQueueConnection = $queueConnection;
107120
}
108121

109122
//Get the DB connections

src/LogToDbCustomLoggingHandler.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,12 @@ function __construct($connection,
7878
if (!empty($collection)) {
7979
$this->saveWithQueue = $enableQueue;
8080
}
81-
if (!empty($detailed)) {
81+
if (!empty($enableQueue)) {
8282
$this->saveWithQueueName = $queueName;
8383
}
84+
if (!empty($queueConnection)) {
85+
$this->saveWithQueueConnection = $queueConnection;
86+
}
8487

8588
parent::__construct($level, $bubble);
8689
}
@@ -94,7 +97,12 @@ protected function write(array $record): void
9497
{
9598
if (!empty($record)) {
9699
try {
97-
$log = new LogToDB($this->connection, $this->collection, $this->detailed, $this->maxRows);
100+
$log = new LogToDB($this->connection,
101+
$this->collection,
102+
$this->detailed,
103+
$this->saveWithQueue,
104+
$this->saveWithQueueName,
105+
$this->saveWithQueueConnection);
98106
$log->newFromMonolog($record);
99107
} catch (\Exception $e) {
100108

0 commit comments

Comments
 (0)