Skip to content

Commit dae2d61

Browse files
committed
updated readme
1 parent 375d828 commit dae2d61

File tree

1 file changed

+29
-8
lines changed

1 file changed

+29
-8
lines changed

readme.md

Lines changed: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ LogToDB::model($channel, $connection, $collection);
9090
You can skip all function variables and the default settings from the config/logtodb.php will be used.
9191
```php
9292
$model = LogToDB::model();
93-
$model->all(); //All logs for defualt channel/connection
93+
$model->get(); //All logs for defualt channel/connection
9494
```
9595

9696
Some more examples of getting logs
@@ -103,10 +103,10 @@ When getting logs for specific channel or DB connection and collection you can e
103103
config/logging.php or connection name from config/databases.php. You can also specify collection/table name if needed as
104104
the third function variable when fetching the model.
105105
```php
106-
$logsFromDefault = LogDB::model()->all();
107-
$logsFromChannel = LogDB::model('database')->all();
108-
$logsFromMysql = LogToDB::model(null, 'mysql')->all();
109-
$logsFromMongoDB = LogToDB::model(null, 'mongodb', 'log')->all();
106+
$logsFromDefault = LogDB::model()->get();
107+
$logsFromChannel = LogDB::model('database')->get();
108+
$logsFromMysql = LogToDB::model(null, 'mysql')->get();
109+
$logsFromMongoDB = LogToDB::model(null, 'mongodb', 'log')->get();
110110
```
111111

112112
##### Custom Model
@@ -132,11 +132,32 @@ class Log extends Model
132132
}
133133
```
134134
Fetching the model trough the LogToDB class (like the examples above) might have some side-effects as tables and connections are
135-
declared dynamically... aka made by Hackermann!
135+
declared dynamically... aka made by Hackerman!
136136
<br>
137137
![](hackerman.gif)
138138

139-
139+
#### Adding tables/expanding collections
140+
The Log handler for SQL expects the following schema:
141+
```php
142+
Schema::create('log', function (Blueprint $table) {
143+
$table->increments('id');
144+
$table->text('message')->nullable();
145+
$table->string('channel')->nullable();
146+
$table->integer('level')->default(0);
147+
$table->string('level_name', 20);
148+
$table->integer('unix_time');
149+
$table->text('datetime')->nullable();
150+
$table->longText('context')->nullable();
151+
$table->text('extra')->nullable();
152+
$table->timestamps();
153+
});
154+
```
155+
This is the migration that ships with this plugin. You can add as many tables as you want, and reference them in the 'collection' config value.
156+
Collection = table, I used the term collection as it works for both SQL/noSQL.
157+
No migrations needed for MongoDB.
158+
159+
No indexes are added per default, so if you fetch a lot of log results based on specific time ranges or types: it might be a good idea to add some indexes.
160+
140161
#### Log Cleanup
141162
There is a helper function to remove the oldest log events and keep a specified number
142163
```php
@@ -166,7 +187,7 @@ LogToDB::removeOlderThen('2019-01-01 23:00:00');
166187
'level' => env('APP_LOG_LEVEL', 'debug'),
167188
'connection' => 'default',
168189
'collection' => 'log'
169-
'detailed; => true,
190+
'detailed' => true,
170191
'queue' => true
171192
'queue_name' => 'logQueue'
172193
'queue_connection' => 'redis'

0 commit comments

Comments
 (0)