Download the PHP package uengage.io/php-logger without Composer

On this page you can find all versions of the php package uengage.io/php-logger. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package php-logger

uengage.io/php-logger

Structured observability logging for uEngage platform services. Write logs to a local file, POST them over HTTP, or emit to stdout - same JSON schema regardless of transport.


Table of Contents


Overview

uengage/logger provides a single Logger class with four log-level methods (info, error, debug, warn). On initialization you choose a transport:

Transport How it works Best for
file Appends NDJSON lines to {basePath}/application/{product}.log EC2/server - CloudWatch Agent, Datadog Agent, or Fluentd ships the file
http POSTs JSON to an HTTP endpoint Environments without a cloud agent
stdout Writes one NDJSON line per entry to php://stdout Lambda (Bref / custom runtime), Docker

The log schema is identical to the Node.js @uengage/logger package - uniform cross-service log analysis.


Requirements


Installation


Quick Start

File transporter (server / EC2)

HTTP transporter (no cloud agent)

Stdout transporter (Lambda / Docker)


Log Schema


Initialization

Validates synchronously; throws \InvalidArgumentException immediately if anything required is missing or invalid.

Config Reference


Transporters

File Transporter

Appends one NDJSON line per entry to {basePath}/application/{product}.log. The directory is created automatically; all services for the same product on a host share one file.

File rotation - when the file reaches maxFileSizeBytes:

Configure your cloud agent to watch application/edge.log* to pick up rotated files. Writes use FILE_APPEND | LOCK_EX - safe for concurrent PHP-FPM workers.


HTTP Transporter

POSTs log entries to an HTTP endpoint via cURL.


Stdout Transporter

Writes one NDJSON line per entry to php://stdout. No config knobs.

Best for AWS Lambda (Bref / custom PHP runtime) and Docker - the runtime captures stdout into CloudWatch Logs or your log-aggregation service. Uses php://stdout rather than the STDOUT constant, which is undefined under PHP-FPM and most Lambda runtime adapters.


Log Methods

Method Signature

Log Options Reference


Level Filtering

Set minLevel to suppress low-priority logs without changing call sites (default: 'warn'):

minLevel DEBUG INFO WARN ERROR
'warn' (default) - -
'info' -
'error' - - -
'debug'

Graceful Shutdown

Transport Action needed
file None - writes are synchronous.
http (immediate, batchSize=1) None - each call fires synchronously.
http (batch, default batchSize=5) Call $logger->destroy() before exit to flush the queue.
stdout None - writes are synchronous.

Register shutdown for HTTP batch mode:


CodeIgniter 2 Integration

Prerequisite - load Composer autoloader

CI2 does not load Composer's autoloader by default. Add one of the following:

Option A - application/config/config.php (recommended):

Option B - index.php (before the CI bootstrap):


Logger_service library

Logger_service acts as a lazy factory for the logger. Load it once per controller; it caches one Logger instance per service name for the lifetime of the request.

1. Load the library in your controller

2. Get a logger and write a log

3. Use from a library / helper (no $this)

How it works internally

What Detail
Factory method get(string $service, string $component = 'edge-server')
Caching One Logger instance per "service:component" key per request
Log file loggerlogs/edge-{service}.log
Min level warn in production, debug in all other environments
Fallback If Logger construction fails, a NullLogger is returned - your code never throws

Tip - dynamic log level


Flushing HTTP batch mode in CI2

Register destroy() via a post_system hook:

Or via register_shutdown_function in your base controller:


CodeIgniter 4 Integration

CI4 includes Composer autoloading out of the box - no manual require needed.

Register as a CI4 Service (app/Config/Services.php):

Use in any Controller, Model, or Library:

Flushing HTTP batch mode - register destroy() in a CI4 After-filter or your BaseController destructor:


PHP-Specific Notes

Behaviour PHP implementation Note
Non-blocking writes Synchronous - writes complete inline PHP has no event loop
flushIntervalMs Accepted in config but no-op Use destroy() instead
UUID generation openssl_random_pseudo_bytes (preferred) or mt_rand fallback
Deep clone json_decode(json_encode($val), true) Equivalent to JS structuredClone()
Timestamp gmdate() + microtime(true) ms Produces Z suffix matching ISO 8601 / Node output
Error output error_log() Visible in /var/log/php_errors.log or Apache/Nginx error log
Concurrent file writes file_put_contents(..., FILE_APPEND \| LOCK_EX) Prevents torn writes from concurrent FPM workers

Examples

Business event - order placed

Engineering error - payment gateway timeout

Warning - rate limit approaching

Debug - database query


Architecture

Error contract: every transporter catches all internal errors and writes to error_log(). A logging failure never throws to the caller.


Running Tests

Expected output:


All versions of php-logger with dependencies

PHP Build Version
Package Version
Requires php Version >=7.1
ext-curl Version *
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package uengage.io/php-logger contains the following files

Loading the files please wait ...