Git Product home page Git Product logo

fcphp-log's Introduction

FcPhp Log

Package to manipulate logs of application FcPhp

Build Status codecov Total Downloads

How to install

Composer:

$ composer require 00f100/fcphp-log

or add in composer.json

{
    "require": {
        "00f100/fcphp-log": "*"
    }
}

How to use

Create logs easy! If $debug = false in constructor, just $log->error() and $log->warning() works...

<?php

use \FcPhp\Log\Log;

/*

    Method to return instance of Log
    
    @param string $directoryOutput Directory to write logs
    @param string|bool $dateFormat Format of date to print log. If `false` not print date
    @param string $extension Extension of file log
    @param bool $debug Enable debug mode
    @return FcPhp\Log\Interfaces\ILog

    Log::getInstance(string $directoryOutput, $dateFormat = 'Y-m-d H:i:s', string $extension = 'log', bool $debug = false) :ILog

*/

$log = Log::getInstance('var/log', 'Y-m-d H:i:s', 'log', true);

// To error logs
$log->error('message of error');
// Print log: var/log/error.log
// [2018-06-16 04:06:25] message of error

// To warning logs
$log->warning('message of warning');
// Print log: var/log/warning.log
// [2018-06-16 04:06:25] message of warning

// To debug
$log->debug('message debug');
// Print log: var/log/debug.log
// [2018-06-16 04:06:25] message debug

// To many types
$log->fooBar('message foo bar');
// Print log: var/log/fooBar.log
// [2018-06-16 04:06:25] message foo bar

Custom format log

<?php

use \FcPhp\Log\Log;

$log = Log::getInstance('var/log', 'Y-m-d H:i:s', 'log', true);

$log->customLog(function(string $dateTime, string $logText, string $breakLine) {
    return $logText . ' ' . $dateTime . $breakLine;
});

$log->error('Custom message, custom format');
// Print log: var/log/error.log
// Custom message, custom format [2018-06-16 04:06:25]

fcphp-log's People

Contributors

00f100 avatar

Stargazers

 avatar

Watchers

 avatar

Forkers

dashbaord202401

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.