Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/apolloeleven/file-logger
https://github.com/apolloeleven/file-logger
Last synced: about 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/apolloeleven/file-logger
- Owner: apolloeleven
- Created: 2018-03-30T11:48:39.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2021-04-15T15:18:41.000Z (over 3 years ago)
- Last Synced: 2024-10-13T01:09:27.001Z (3 months ago)
- Language: PHP
- Size: 30.3 KB
- Stars: 3
- Watchers: 8
- Forks: 1
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# File-logger
Installation
------------The preferred way to install this extension is through [composer](http://getcomposer.org/download/).
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 ##
```php
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
```