PHPackages                             myoperator/centrallog - 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. myoperator/centrallog

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

myoperator/centrallog
=====================

MyOperator package for detailed logging

v1.0(6y ago)0123[1 issues](https://github.com/myoperator/centrallog/issues)GPLPHPPHP &gt;=5.5.9

Since Jun 25Pushed 6y agoCompare

[ Source](https://github.com/myoperator/centrallog)[ Packagist](https://packagist.org/packages/myoperator/centrallog)[ RSS](/packages/myoperator-centrallog/feed)WikiDiscussions master Synced 3d ago

READMEChangelogDependencies (1)Versions (2)Used By (0)

MyOperator CentralLog
=====================

[](#myoperator-centrallog)

This library is intended to be used as a basic `log4php` wrapper to log in our desired pattern.

Features
--------

[](#features)

- Namespaces and defines
- PSR-4 autoloading compliant structure
- Default detail log compatible configurator
- One log location centrally

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

[](#installation)

You can easily install this package by adding following section in your composer.json:

```
"repositories": [
        {
            "type": "vcs",
            "url": "https://github.com/myoperator/centrallog.git"
        }
    ]

```

and then doing: `composer require myoperator/centrallog:dev-master`

or by adding following to your composer.json:

```
  "require": {
        "myoperator/centrallog": "dev-master"
  }

```

The `composer.json` will look like

```
{
    "require": {
        "myoperator/centrallog": "dev-master"
    },
    "repositories": [
        {
            "type": "vcs",
            "url": "https://github.com/myoperator/centrallog.git"
        }
    ]
}
```

Usage
-----

[](#usage)

1. Include `vendor/autoload` in your project

```
   include_once 'vendor/autoload.php';
```

2. Configure the logger

```
  use \MyOperator\CentralLog;

  CentralLog::configure('mylog.log'); //logs.log refers to log output file
```

3. Get the logger and log anything

```
  $log = CentralLog::getLogger('myLogger');
  $log->log("Something");
```

Overall, this can be summarised as

```
include_once 'vendor/autoload.php';
use \MyOperator\CentralLog;

CentralLog::configure("mylog.log");

$log = CentralLog::getLogger('myLogger');
$log->log("Something");

//Or you can also provide the title
$log->withTitle("Making curl request")->log("curl response");
```

Configurations
--------------

[](#configurations)

The logger is adjusted to be configured as per myoperator specific logs. Hence, following params can be passed to the `configure` method.

```
  CentralLog::configure(string  $outputpath = null, string  $server = null, string|\MyOperator\class  $class = null, string  $pattern = null, string  $maxsize = null)
```

Parameters

```
string	$outputpath	Output path of the log file

string	$server	Server on which the application is running. Ex- S6, API01

string	$class	Class name under which the logger is being used

string	$pattern	logger pattern as described in https://logging.apache.org/log4php/docs/layouts/pattern.html

string	$maxsize	Maximum size per log
```

Available methods
-----------------

[](#available-methods)

### Logging General log

[](#logging-general-log)

Any log can be logged with following method signature

```
   CentralLog::log(mixed  $message, string  $uid = null,  integer  $acl = null, string $loglevel="info")
```

Parameters

```
mixed	$message	Item to be logged

string	$uid	The unique id of item. In case of sync script, this can be engine uid. (optional)

integer	$acl	The ACL to be used to log the item. (optional). Can be one of [1,2,4]

string	$loglevel The loglevel to use for the log. defaults to `info`. (optional)
```

Note that none of support/developer/client log method needs `$acl` parameter as it is obvious which `$acl` is going to be used

### Logging with title

[](#logging-with-title)

Titles helps contextiying log domain. It provides a way to recognize activities in logs. To make logs more readable, you can provide log titles with `->withTitle($title)` or `->title($title)`. For instance -

```
  $logger->withTitle($title)->log($message, $uid, $acl);
  //This is same as above
  $logger->title($title)->log($message, $uid, $acl);
```

### Logging support logs

[](#logging-support-logs)

```
   $logger->slog(mixed  $message, string  $uid = null, string  $level = null)
```

### Logging client logs

[](#logging-client-logs)

```
   $logger->clog(mixed  $message, string  $uid = null, string  $level = null)
```

### Logging developer logs

[](#logging-developer-logs)

```
   $logger->dlog(mixed  $message, string  $uid = null, string  $level = null);
```

### Logging combined logs

[](#logging-combined-logs)

Sometimes, you may wish to log different types of responses for same event. You can easily do as by setting different messages in following message keys:

```
   $message = array(
                  'dmsg' => 'Your developer log here',
                  'smsg' => 'Your support log here',
                  'cmsg' => 'Your customer log here'
              );
```

For instance, in case of an exception, you may want to send the stack trace to developer, exception message to support, and the string *Error occured* to end customer. This can be easily accomplished by implementing `log` as:

```
    try{
      throw new \Exception("Application error....", 400);
    } catch (\Exception $e) {
      $log->log(['dmsg' => $e, 'cmsg' => 'Some error occured', 'smsg' => $e->getMessage()]);
    }
```

Viewing documentation
---------------------

[](#viewing-documentation)

This package uses phpdoc to generate documentation. You can generate the package documentation by cloning the repository and installing dev dependencies

```
    composer update --dev
```

and then using `phpdoc` to generate reference documentation by

```
   phpdoc -d src/

```

Todo
----

[](#todo)

- Add phpunit testcases

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity54

Maturing project, gaining track record

 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.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

2515d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/13e9ef65aca6c94519bd96b589043034c126905d9d219f0d1d2362c9a06482ff?d=identicon)[codeasashu](/maintainers/codeasashu)

---

Top Contributors

[![codeasashu](https://avatars.githubusercontent.com/u/1492350?v=4)](https://github.com/codeasashu "codeasashu (13 commits)")

---

Tags

composer-packagemyoperatorphp

### Embed Badge

![Health badge](/badges/myoperator-centrallog/health.svg)

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

###  Alternatives

[psr/log

Common interface for logging libraries

10.4k1.2B9.2k](/packages/psr-log)[itsgoingd/clockwork

php dev tools in your browser

5.9k27.6M94](/packages/itsgoingd-clockwork)[graylog2/gelf-php

A php implementation to send log-messages to a GELF compatible backend like Graylog2.

41838.2M138](/packages/graylog2-gelf-php)[bugsnag/bugsnag-psr-logger

Official Bugsnag PHP PSR Logger.

32132.5M2](/packages/bugsnag-bugsnag-psr-logger)[consolidation/log

Improved Psr-3 / Psr\\Log logger based on Symfony Console components.

15462.2M7](/packages/consolidation-log)[datadog/php-datadogstatsd

An extremely simple PHP datadogstatsd client

19124.6M15](/packages/datadog-php-datadogstatsd)

PHPackages © 2026

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