@@ -116,6 +116,27 @@ In progress...
116
116
117
117
## Advanced
118
118
119
+ #### Custom location
120
+
121
+ Sometimes it' s needed to change location of the log files, for example, you want it to be dependent on some command' s argument.
122
+ If that is your case, just override `getLogPath` method in your command class:
123
+
124
+ ```php
125
+ class Foo extends Command
126
+ {
127
+ use Loggable;
128
+
129
+ protected function getLogPath()
130
+ {
131
+ $name = Str::replaceFirst(' :' , ' /' , $this->getName());
132
+ $baz = $this->argument(' baz' );
133
+ return storage_path("logs/{$name}/{$baz}/date.log");
134
+ }
135
+
136
+ // ...
137
+ }
138
+ ```
139
+
119
140
#### Accessing Monolog instance
120
141
121
142
This package is using [Monolog logging library](https://packagist.org/packages/monolog/monolog) with all of it' s power.
@@ -126,12 +147,12 @@ If needed, you may access the underlying Monolog instance in a two ways:
126
147
class Foo extends Command
127
148
{
128
149
use Loggable;
129
-
150
+
130
151
public function handle()
131
152
{
132
153
$log = $this->icLogger();
133
154
}
134
-
155
+
135
156
// ...
136
157
}
137
158
```
@@ -141,27 +162,6 @@ If needed, you may access the underlying Monolog instance in a two ways:
141
162
$log = $app(' log.iclogger' );
142
163
```
143
164
144
- #### Custom location
145
-
146
- Sometimes it' s needed to change location of the log files, for example, you want it to be dependent on some command' s argument.
147
- If that is your case, just override `getLogPath` method in your command class:
148
-
149
- ```php
150
- class Foo extends Command
151
- {
152
- use Loggable;
153
-
154
- protected function getLogPath()
155
- {
156
- $name = Str::replaceFirst(' :' , ' /' , $this->getName());
157
- $baz = $this->argument(' baz' );
158
- return storage_path("logs/{$name}/{$baz}/date.log");
159
- }
160
-
161
- // ...
162
- }
163
- ```
164
-
165
165
## Troubleshooting
166
166
167
167
#### Trait included, but nothing happens?
0 commit comments