orz / plog
PSR3 logging library that is PDO extendable and simple to use
v0.1.1-stable
2022-04-25 04:20 UTC
Requires
- php: >=7.0
- ext-pdo: *
Requires (Dev)
- phpunit/phpunit: ^9.0
Suggests
- ext-pdo_dblib: For MSSQL or Sybase database on Linux/UNIX platform
- ext-pdo_mysql: For MySQL or MariaDB database
- ext-pdo_oci: For Oracle database
- ext-pdo_pqsql: For PostgreSQL database
- ext-pdo_sqlite: For SQLite database
- ext-pdo_sqlsrv: For MSSQL database on both Window/Liunx platform
This package is auto-updated.
Last update: 2025-03-18 09:59:59 UTC
README
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.