Skip to content

PSR3 logging library that is PDO extendable and simple to use

License

Notifications You must be signed in to change notification settings

huanguan1978/plog

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

plog

PSR-3 logging library that is PDO extendable and simple to use

Features

  • single file
  • singleton pattern
  • six log levels (info, notice, debug, warning, error, fatal)
  • Plogger, dsn support mysql, pgsql, sqlsrv, sqlite.

TextLog Basic Usage

use Plog\Tlogger;
$tlog = Tlogger::getInstance();
$tlog->info('HelloWorld');
$tlog->debug("I'mHere",['data'=>['123','456']]);

TextLog Output

[2022-04-16 16:43:08] [test2.localhost.localdomain/xz/plog/demo.php] [12] : [INFO] - HelloWorld 
[2022-04-16 16:43:08] [test2.localhost.localdomain/xz/plog/demo.php] [13] : [DEBUG] - I'mHere {"data":["123","456"]}

PdoLog Basic Usage

use Plog\Plogger;
$dbtype = 'sqlite';
$dbname = 'plog.db';
$dbtable = 'plog';
$dsn = sprintf("%s:%s", $dbtype, $dbname);
$plnk = new PDO($dsn);
$plog = Plogger::getInstance();
$plog->dblink($plnk);
$plog->dbtype($dbtype);
$plog->dbtable($dbtable, true);
$plog->info('HelloWorld');
$plog->debug("I'mHere",['data'=>['123','456',"I'm"]]);

PdoLog Output

SELECT * FROM plog;
id time path line severity message context
1 2022-04-16 16:29:30 test2.localhost.localdomain/xz/plog/demo.php 25 INFO HelloWorld
2 2022-04-16 16:29:30 test2.localhost.localdomain/xz/plog/demo.php 26 DEBUG ImHere {"data":["123","456","I\u0027m"]}

Installation

Install the latest version with:

$ composer require orz/plog

Usage without composer

Download ZIP See demo2.php.

About

PSR3 logging library that is PDO extendable and simple to use

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages