PHP code example of mosetek / logger

1. Go to this page and download the library: Download mosetek/logger library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

mosetek / logger example snippets


$logger = new Logger();

$logger = new Logger('some/path/', 'filename'); 

$logger = new Logger('some/path', 'filename', 'H:i:s');

$logger->getPath();        //Returns: some/path/to/
$logger->getFullPath();    //Returns: some/path/to/file.txt
$logger->getFilename();    //Returns: file.txt
$logger->getDateFormat();  //Returns: Y-m-d H:i:s

$logger->setPath('some/new/path');
$logger->setFilename('new_filename.txt');
$logger->setDateFormat('Y-m');

$logger->log('some log content');
$logger->log(['some' => ['nice', 'array']);

$logger->log('some log content', 3);
//That makes your log file looks like that:
// 2019-09-01 12:02:32 | [WARNING] | some log content

$logger->log('some log content on custom path', 0, 'custom/path/to/log.txt');

$logger->text('Hello world');

$logger->text('Hello world', ', ');
$logger->text('bye world.', PHP_EOL);
$logger->text('New line, world');

$logger->read();

$logger->read('some/path/to/file.txt');

$logger->dump(['some' => ['example', 'array']]);

$logger->send('[email protected]');

$logger->move('new/path/to/file.log');

$logger->move('new/path/to/file.log', 'file/to/move.log');

$logger->copy('where/to/copy/file.txt');

$logger->copy('where/to/copy/file.txt', 'what/file/to/copy.txt);

$logger->wipe();

$logger->wipe('some/path/to/file.txt');

$logger->drop();

$logger->drop('some/path/to/file.txt');

$logger->getFilesize();

$logger->getFilezise();       //Returns in megabytes
$logger->getFilezise('B');    //Returns in bytes
$logger->getFilezise('KB');   //Returns in kilobytes
$logger->getFilezise('GB');   //Returns in gigabytes

$logger->getFilesize('MB', 'path/to/file.txt');