Skip to content

Commit

Permalink
Added readme and small fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
giolaza committed Jun 29, 2020
1 parent 648f091 commit 504839f
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 10 deletions.
11 changes: 2 additions & 9 deletions Log.php
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ public static function logError($text, $filename = 'logs.php', $engineForceStop

//end writing

if ($engineForceStop){
if ($engineForceStop) {
die(PHP_EOL . 'Log saved...' . '<br>' . PHP_EOL . 'Engine force stop...' . PHP_EOL);
}
}
Expand Down Expand Up @@ -207,14 +207,7 @@ public static function showLog($string)
. '<!-- ----------------------------------------------------------------------------- -->' . PHP_EOL
. '<!-- ----------------------------------------------------------------------------- -->' . PHP_EOL;


if (isset($_GET['method']) && $_GET['method'] == 'json') {
global $err;
$err .= $text;
} else {
echo $text;
}

echo $text;
}

/**
Expand Down
51 changes: 51 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# Logger by GioLaza

Logger for engine

## Installation

```bash
composer require giolaza/logger
```

## Configuration

```php
define('GIOLAZA_SHOW_ERRORS', false, 1);
define('GIOLAZA_SAVE_ERRORS', true, 1);
define('GIOLAZA_LOGS_FOLDER', __DIR__ . '/../___productionLogs', 1);
```

Constant `GIOLAZA_SHOW_ERRORS` defines display detail information about error or not. if value is `false` engine will print `something went wrong`.


Constant `GIOLAZA_SAVE_ERRORS` defines save detail information about error in files or not.


Constant `GIOLAZA_LOGS_FOLDER` defines log folder link. It's recommended to use folder outside root folder or add `.htaccess` to restrict direct access from `www`

## Usage
```php
GioLaza\Logger\Log::logError(text: 'ANY TEXT',filename: 'filename.log', engineForceStop: true, dispalyErrors: true)
```
`engineForceStop` - means need or not use `die`
`dispalyErrors` - is method variable, if constant allows show errors, method will print it.

```php
GioLaza\Logger\Log::logError(text: 'DB connection error ',filename: 'db.log')
```
This code will print your text,save text to file and force stop php execution

```php
GioLaza\Logger\Log::logError(text: 'DB connection error ',filename: 'db.log',engineForceStop: true, dispalyErrors: false)
```
This code will NOT print your text,save text in file and force stop php execution


```php
GioLaza\Logger\Log::logError(text: 'User id: 12 ',filename: 'db.log',engineForceStop: true, dispalyErrors: false)
```
This code will NOT print your text or force stop php execution, just save text in file

## License
[MIT](https://choosealicense.com/licenses/mit/)
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "giolaza/logger",
"type": "library",
"version": "1.0.2",
"version": "1.0.3",
"authors": [
{
"name": "Giorgi Lazashvili",
Expand Down

0 comments on commit 504839f

Please sign in to comment.