1414use Tempest \DateTime \Duration ;
1515use Tempest \EventBus \EventBus ;
1616use Tempest \Log \Channels \AppendLogChannel ;
17- use Tempest \Log \Channels \DailyLogChannel ;
18- use Tempest \Log \Channels \WeeklyLogChannel ;
17+ use Tempest \Log \Config \DailyLogConfig ;
18+ use Tempest \Log \Config \MultipleChannelsLogConfig ;
19+ use Tempest \Log \Config \NullLogConfig ;
20+ use Tempest \Log \Config \SimpleLogConfig ;
21+ use Tempest \Log \Config \WeeklyLogConfig ;
1922use Tempest \Log \GenericLogger ;
20- use Tempest \Log \LogConfig ;
2123use Tempest \Log \LogLevel ;
2224use Tempest \Log \MessageLogged ;
2325use Tempest \Support \Filesystem ;
@@ -41,15 +43,11 @@ protected function cleanup(): void
4143 }
4244
4345 #[Test]
44- public function append_log_channel (): void
46+ public function simple_log_config (): void
4547 {
4648 $ filePath = __DIR__ . '/logs/tempest.log ' ;
4749
48- $ config = new LogConfig (
49- channels: [
50- new AppendLogChannel ($ filePath ),
51- ],
52- );
50+ $ config = new SimpleLogConfig ($ filePath , prefix: 'tempest ' );
5351
5452 $ logger = new GenericLogger ($ config , $ this ->container ->get (EventBus::class));
5553 $ logger ->info ('test ' );
@@ -59,15 +57,11 @@ public function append_log_channel(): void
5957 }
6058
6159 #[Test]
62- public function daily_log_channel (): void
60+ public function daily_log_config (): void
6361 {
6462 $ clock = $ this ->clock ();
6563 $ filePath = __DIR__ . '/logs/tempest- ' . date ('Y-m-d ' ) . '.log ' ;
66- $ config = new LogConfig (
67- channels: [
68- new DailyLogChannel (__DIR__ . '/logs/tempest.log ' ),
69- ],
70- );
64+ $ config = new DailyLogConfig (__DIR__ . '/logs/tempest.log ' , prefix: 'tempest ' );
7165
7266 $ logger = new GenericLogger ($ config , $ this ->container ->get (EventBus::class));
7367 $ logger ->info ('test ' );
@@ -85,14 +79,10 @@ public function daily_log_channel(): void
8579 }
8680
8781 #[Test]
88- public function weekly_log_channel (): void
82+ public function weekly_log_config (): void
8983 {
9084 $ filePath = __DIR__ . '/logs/tempest- ' . date ('Y-W ' ) . '.log ' ;
91- $ config = new LogConfig (
92- channels: [
93- new WeeklyLogChannel (__DIR__ . '/logs/tempest.log ' ),
94- ],
95- );
85+ $ config = new WeeklyLogConfig (__DIR__ . '/logs/tempest.log ' , prefix: 'tempest ' );
9686
9787 $ logger = new GenericLogger ($ config , $ this ->container ->get (EventBus::class));
9888 $ logger ->info ('test ' );
@@ -107,11 +97,12 @@ public function multiple_same_log_channels(): void
10797 $ filePath = __DIR__ . '/logs/multiple-tempest1.log ' ;
10898 $ secondFilePath = __DIR__ . '/logs/multiple-tempest2.log ' ;
10999
110- $ config = new LogConfig (
100+ $ config = new MultipleChannelsLogConfig (
111101 channels: [
112102 new AppendLogChannel ($ filePath ),
113103 new AppendLogChannel ($ secondFilePath ),
114104 ],
105+ prefix: 'tempest ' ,
115106 );
116107
117108 $ logger = new GenericLogger ($ config , $ this ->container ->get (EventBus::class));
@@ -131,11 +122,9 @@ public function multiple_same_log_channels(): void
131122 public function log_levels (mixed $ level , string $ expected ): void
132123 {
133124 $ filePath = __DIR__ . '/logs/tempest.log ' ;
134- $ config = new LogConfig (
125+ $ config = new SimpleLogConfig (
126+ path: $ filePath ,
135127 prefix: 'tempest ' ,
136- channels: [
137- new AppendLogChannel ($ filePath ),
138- ],
139128 );
140129
141130 $ logger = new GenericLogger ($ config , $ this ->container ->get (EventBus::class));
@@ -157,19 +146,17 @@ public function message_logged_emitted(LogLevel $level, string $_expected): void
157146 $ this ->assertSame (['foo ' => 'bar ' ], $ event ->context );
158147 });
159148
160- $ logger = new GenericLogger (new LogConfig (), $ eventBus );
149+ $ logger = new GenericLogger (new NullLogConfig (), $ eventBus );
161150 $ logger ->log ($ level , 'This is a log message of level: ' . $ level ->value , context: ['foo ' => 'bar ' ]);
162151 }
163152
164153 #[Test]
165154 public function different_log_levels (): void
166155 {
167156 $ filePath = __DIR__ . '/logs/tempest.log ' ;
168- $ config = new LogConfig (
157+ $ config = new SimpleLogConfig (
158+ path: $ filePath ,
169159 prefix: 'tempest ' ,
170- channels: [
171- new AppendLogChannel ($ filePath ),
172- ],
173160 );
174161
175162 $ logger = new GenericLogger ($ config , $ this ->container ->get (EventBus::class));
0 commit comments