A simple and lightful logger for PHP
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
media
.gitattributes
.gitignore
Logger.php
README.md
composer.json
composer.lock
demo.php

README.md

Logger

What is it

A simple and lightful logger for PHP

Logger是什么

一个简洁的、轻量级的PHP日志工具

Installation

composer require blogdaren/logger

Dependencies

  • packagist: blogdaren/custom-terminal-color

Usage

<?php
require_once dirname(__FILE__) . '/vendor/autoload.php';
use Logger\Logger;

while(1)
{
    usleep(500000);
    Logger::info('with INFO level');
    Logger::debug('with DEBUG level');
    Logger::warning('with WARNING level');
    Logger::error('with ERROR level');
    Logger::crazy('with CRAZY level');
}

Usage

1、Available Method:

Logger::show($arg1, $arg2, $arg3, $arg4);
Logger::info($arg1, $arg3, $arg4);
Logger::debug($arg1, $arg3, $arg4);
Logger::warning($arg1, $arg3, $arg4);
Logger::error($arg1, $arg3, $arg4);
Logger::crazy($arg1, $arg3, $arg4);

2、The method listed above share the same arguments:

* $arg1: message to be logged
* $arg2: log level with 5 options: 
  >> Logger::LOG_LEVEL_INFO
  >> Logger::LOG_LEVEL_DEBUG
  >> Logger::LOG_LEVEL_WARN
  >> Logger::LOG_LEVEL_ERROR
  >> Logger::LOG_LEVEL_CRAZY
* $arg3: whether to print log or not on terminal, default `true`
* $arg4: where to store log file, default `/tmp/default.log`, or u can leave it empty then will do nothing

Demostrate

demo1

demo2

Related links and thanks