Skip to content

apolloeleven/file-logger

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

36 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

File-logger

Installation

The preferred way to install this extension is through composer.

Either run

php composer.phar require --prefer-dist apollo11/file-logger "*"

or add

"apollo11/file-logger": "*"

to the require section of your composer.json file.

Basic usage

include_once 'FileColor.php';
include_once 'FileLogger.php';

$logger = new \apollo11\fileLogger\FileLogger([
    'logFilePath' => dirname(__FILE__) . '/logs',
    'logFileName' => 'test12.log',
    'logFileDateFormat' => "Y_m_d_H_i_s",
    'logFileTemplate' => '{date}_{fileName}',
    'logTextDateFormat' => 'Y-m-d',
    'logTextTemplate' => '{date} [{type}] - {message}' . PHP_EOL,
]);

for ($i = 0; $i < 20; $i++){
    $logger->log("My test $i", \apollo11\fileLogger\FileColor::F_WHITE, \apollo11\fileLogger\FileColor::B_GREEN);
}

Logger Options

Log file creation types (const)
FILE_CREATE_TYPE_BY_TIME     //recreate log file by time
FILE_CREATE_TYPE_BY_SIZE    //recreate log file by size
Color
enableColors       //colored text for logs , deafult value true
Save latest logs
saveLatestFileNumber       // bool/integer , deafult value 100 (will save only last 100 log files)
Force create Directory
//Force create directory if it does not exist
//Throws error if directory path was invalid  
      
forceCreateDirectory   // bool default value false 
Log file recreation type
fileCreateType     //log file creation type  , default value   "FILE_CREATE_TYPE_BY_TIME"
Log file recreation days
Add  this properties if file recreation type set to   "FILE_CREATE_TYPE_BY_TIME"

fileReCreateDays        //  (integer)

Log file recreation size
Add this property if file recreation type set to   "FILE_CREATE_TYPE_BY_SIZE"

filReCreateSize = 900; //size in bytes
Log file attributes
logFilePath             // full path to log file
logFileName             // log file name   "example.log"
logFileDateFormat       // log file date format default value   "Y_m_d"
logFileTemplate         // log file template deafault value   "{date}_{fileName}"
Log text attributes
logTextDateFormat       // log text date format default value   "Y-m-d H:i:s"
logTextTemplate         // log text template default value   "[ {date} | {type} ] - {message} " . PHP_EOL

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published

Contributors 3

  •  
  •  
  •  

Languages