-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbasic.php
More file actions
35 lines (27 loc) · 962 Bytes
/
basic.php
File metadata and controls
35 lines (27 loc) · 962 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
<?php
declare(strict_types=1);
require __DIR__ . '/../vendor/autoload.php';
use LogTide\SDK\LogTideClient;
use LogTide\SDK\Models\LogTideClientOptions;
// Initialize client
$client = new LogTideClient(new LogTideClientOptions(
apiUrl: 'http://localhost:8080',
apiKey: 'lp_your_api_key_here',
));
// Send simple logs
$client->info('api-gateway', 'Server started', ['port' => 3000]);
$client->warn('cache', 'Cache miss', ['key' => 'user:123']);
// Error with exception
try {
throw new \RuntimeException('Database connection timeout');
} catch (\Exception $e) {
$client->error('database', 'Connection failed', $e);
}
// With trace ID context
$client->withTraceId('request-123', function() use ($client) {
$client->info('api', 'Processing request');
$client->info('database', 'Querying users');
$client->info('api', 'Sending response');
});
// Auto-flush and cleanup on shutdown
echo "Logs sent! Check your LogTide dashboard.\n";