PHPackages                             borneo/logger - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Logging &amp; Monitoring](/categories/logging)
4. /
5. borneo/logger

ActiveLibrary[Logging &amp; Monitoring](/categories/logging)

borneo/logger
=============

A lightweight PHP SDK for sending structured event logs to any HTTP ingest endpoint.

00PHP

Since Jun 10Pushed yesterdayCompare

[ Source](https://github.com/EgiGrivandani/borneo-logger)[ Packagist](https://packagist.org/packages/borneo/logger)[ RSS](/packages/borneo-logger/feed)WikiDiscussions main Synced today

READMEChangelogDependenciesVersions (1)Used By (0)

Borneo Logger
=============

[](#borneo-logger)

A lightweight PHP SDK for sending structured event logs to any HTTP ingest endpoint — ideal for audit trails, user activity tracking, and application monitoring.

Installation
------------

[](#installation)

```
composer require borneo/logger
```

Dispatch Modes
--------------

[](#dispatch-modes)

BorneoLogger supports two modes, auto-detected based on configuration:

ModeHowLatencyRecommended**Mode 1 — File**Writes JSON to a local log file. A log shipper (e.g. [Vector](https://vector.dev)) tails and ships it.~0.01ms✅ Production**Mode 2 — HTTP**Fire-and-forget HTTP POST directly to the ingest endpoint.~0.5msFallback / simple setupsConfiguration
-------------

[](#configuration)

Call `configure()` once in your application bootstrap or config file:

```
use Borneo\BorneoLogger;

// Mode 1 — File (recommended for production)
BorneoLogger::configure(
    endpoint: 'https://your-ingest-endpoint.com/logs',
    apiKey:   'your-api-key',
    service:  'your-service-name',
    logFile:  '/var/log/app/events.log'  // a log shipper tails this file
);

// Mode 2 — HTTP fallback (no logFile needed)
BorneoLogger::configure(
    endpoint: 'https://your-ingest-endpoint.com/logs',
    apiKey:   'your-api-key',
    service:  'your-service-name'
);
```

Usage
-----

[](#usage)

### Auth Events

[](#auth-events)

```
// Successful login
BorneoLogger::loginSuccess($userId);

// Failed login (great for brute-force detection)
BorneoLogger::loginFailed('wrong_password');

// Logout
BorneoLogger::logout($userId);
```

### HTTP Request Logging

[](#http-request-logging)

Best placed in API Gateway or middleware, **after** the response is sent:

```
BorneoLogger::httpRequest(
    method:     'POST',
    path:       '/api/checkout',
    statusCode: 200,
    latencyMs:  143,
    userId:     $userId,
    traceId:    $traceId
);
```

Status is automatically derived: `success` (2xx), `failed` (4xx), `error` (5xx).

### Exception &amp; Error Logging

[](#exception--error-logging)

```
// Catch any Throwable (ideal in a global exception handler)
set_exception_handler(fn($e) => BorneoLogger::exception($e, $userId));

// Generic error without an exception object
BorneoLogger::error('Payment gateway timeout', ['gateway' => 'midtrans'], $userId);
```

### Custom Events

[](#custom-events)

```
BorneoLogger::log('payment.created', [
    'user_id'  => 123,
    'status'   => 'success',
    'metadata' => ['amount' => 50000, 'method' => 'transfer'],
]);
```

`metadata` accepts any array — it will be auto-encoded to a JSON string.

Log Payload Structure
---------------------

[](#log-payload-structure)

Each log entry is dispatched as a JSON object:

```
{
  "timestamp":  "2026-06-10T09:42:24.123Z",
  "service":    "your-service-name",
  "event_type": "user.login",
  "status":     "success",
  "user_id":    123,
  "ip":         "1.2.3.4",
  "user_agent": "Mozilla/5.0...",
  "metadata":   "{\"amount\":50000,\"method\":\"transfer\"}"
}
```

Advanced Usage
--------------

[](#advanced-usage)

### Dependency Injection

[](#dependency-injection)

Use BorneoLogger as an instance — the service name is scoped to that instance only and does **not** affect the global configuration:

```
$logger = new BorneoLogger('payment-service');
$logger->send('order.shipped', ['order_id' => 456]);
```

### Per-call Service Override

[](#per-call-service-override)

```
BorneoLogger::log('inventory.updated', ['item_id' => 789], 'warehouse-service');
```

Requirements
------------

[](#requirements)

- PHP &gt;= 8.0
- `allow_url_fopen = On` (required for Mode 2 HTTP)

License
-------

[](#license)

MIT

###  Health Score

20

—

LowBetter than 13% of packages

Maintenance65

Regular maintenance activity

Popularity0

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity11

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/71784139?v=4)[eden griv ](/maintainers/egriv)[@egriv](https://github.com/egriv)

---

Top Contributors

[![EgiGrivandani](https://avatars.githubusercontent.com/u/59734794?v=4)](https://github.com/EgiGrivandani "EgiGrivandani (3 commits)")

### Embed Badge

![Health badge](/badges/borneo-logger/health.svg)

```
[![Health](https://phpackages.com/badges/borneo-logger/health.svg)](https://phpackages.com/packages/borneo-logger)
```

###  Alternatives

[psr/log

Common interface for logging libraries

10.4k1.2B10.8k](/packages/psr-log)[open-telemetry/api

API for OpenTelemetry PHP.

1938.5M259](/packages/open-telemetry-api)[open-telemetry/sdk

SDK for OpenTelemetry PHP.

2326.5M315](/packages/open-telemetry-sdk)[illuminated/console-logger

Logging and Notifications for Laravel Console Commands.

8676.7k](/packages/illuminated-console-logger)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
