Giter Site home page Giter Site logo

zend-log-extensions's Introduction

Repository abandoned 2019-12-31

This repository has moved to Slamdunk/laminas-log-extensions.

Slam Zend\Log extensions

Build Status Code Coverage Packagist

Extensions for Zend\Log

Installation

Execute:

composer require slam/zend-log-extensions

Usage

The main functionality of this package is the RotateStream writer. PHP cannot handle files larger than 2 GB, so if you log a lot you can end up losing some if you reach this limit.

Slam\Zend\Log\Writer\RotateStream rotates the write when it reaches ~1.5 GB.

use Slam\Zend\Log\Writer\RotateStream;
use Zend\Log\Formatter\Simple;
use Zend\Log\Logger;

$writer = new RotateStream(__DIR__ . '/log.txt');
$writer->setFormatter(new Simple());

// Do the check everytime, defaults to once every 100000 log entries
$writer->setCheckProbability(1);
// 10 bytes max file size, defaults to ~1.5 GB
$writer->setMaxFileSize(10);

$logger = new Logger();
$logger->addWriter($writer);

for ($i = 0; $i < 10; ++$i) {
    $logger->info($i);
    sleep(1);
}

This is what you'll find in the directory:

$ ls log.txt*
log.txt  log.txt.1  log.txt.2  log.txt.3  log.txt.4  log.txt.5  log.txt.6  log.txt.7  log.txt.8  log.txt.9

$ cat log.txt.9
2017-09-05T11:08:46+02:00 INFO (6): 8
2017-09-05T11:08:47+02:00 NOTICE (5): LOG ROTATE

$ cat log.txt
2017-09-05T11:08:47+02:00 INFO (6): 9

zend-log-extensions's People

Contributors

slamdunk avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.