MAKS\AmqpAgent\Helper\Logger
A class to write logs, exposing methods that work statically and on instantiation.
This class DOES NOT implement `Psr\Log\LoggerInterface`.
Example:
```
// static
Logger::log('Some message to log.', 'filename', 'path/to/some/directory');
// instantiated
$logger = new Logger();
$logger->setFilename('filename');
$logger->setDirectory('path/to/some/directory');
$logger->write('Some message to log.');
```
Synopsis
- // members
- public $filename;
- public $directory;
- // methods
- public void __construct()
- public bool write()
- public string getFilename()
- public Logger setFilename()
- public string getDirectory()
- public Logger setDirectory()
- public static bool log()
- protected static string getFallbackFilename()
- protected static string getFallbackDirectory()
- protected static string getNormalizedPath()
Coverage
Methods | 100% | 10 / 10 |
Lines | 100% | 49 / 49 |
Members
public
- $directory
—
string
The directory where the log file gets written. - $filename
—
string
The filename of the log file.
Methods
protected
- getFallbackDirectory() — Returns a fallback writing directory based on caller.
- getFallbackFilename() — Returns a fallback filename based on date.
- getNormalizedPath() — Returns a normalized path based on OS.
public
- __construct() — Passing null for $directory will raise a warning and force the logger to find a reasonable directory to write the file in.
- getDirectory() — Gets directory property.
- getFilename() — Gets filename property.
- log() — Logs a message to a file, generates it if it does not exist and raises a user-level warning and/or notice on misuse.
- setDirectory() — Sets directory property.
- setFilename() — Sets filename property.
- write() — Logs a message to a file, generates it if it does not exist and raises a user-level warning and/or notice on misuse.
History
-
2021-01-12T21:10:22+00:00 (commit #21ff66e)
Author: Marwan Al-Soltany (MarwanAlsoltany@gmail.com) / Commiter: Marwan Al-Soltany (MarwanAlsoltany@gmail.com)
Update logger class * Fix typos * Update DocBlocks
-
2021-01-12T21:10:21+00:00 (commit #9cdb22d)
Author: Marwan Al-Soltany (MarwanAlsoltany@gmail.com) / Commiter: Marwan Al-Soltany (MarwanAlsoltany@gmail.com)
Update logger class * Fix a wrong parameter type passed to file_put_contents() function
-
2021-01-12T21:10:21+00:00 (commit #d09424b)
Author: Marwan Al-Soltany (MarwanAlsoltany@gmail.com) / Commiter: Marwan Al-Soltany (MarwanAlsoltany@gmail.com)
Add strict types declaration * Add declare(strict_types=1) to all files * Fix file header DocBlock spacing of all files
-
2020-11-29T09:05:57+00:00 (commit #e91aecf)
Author: Marwan Al-Soltany (MarwanAlsoltany@gmail.com) / Commiter: Marwan Al-Soltany (MarwanAlsoltany@gmail.com)
Update logger class * Fix an issue with log() method when checking for file size
-
2020-09-30T13:01:27+00:00 (commit #5561105)
Author: Marwan Al-Soltany (MarwanAlsoltany@gmail.com) / Commiter: Marwan Al-Soltany (MarwanAlsoltany@gmail.com)
Update logger class * Fix coding style issue
-
2020-09-30T11:49:41+00:00 (commit #4699ce4)
Author: Marwan Al-Soltany (MarwanAlsoltany@gmail.com) / Commiter: Marwan Al-Soltany (MarwanAlsoltany@gmail.com)
Refactor logger class * Add getFallbackFilename method * Add getFallbackDirectory method * Add getNormalizedPath method
-
2020-09-26T21:02:40+00:00 (commit #082fd7a)
Author: Marwan Al-Soltany (MarwanAlsoltany@gmail.com) / Commiter: Marwan Al-Soltany (MarwanAlsoltany@gmail.com)
Update logger class * Refactor fallback path guessing when no path is specified. * Fix an issue introduced by mistake in ba308fc834160a9d27e72e1bb43ff7f4645d9111
-
2020-09-26T17:47:14+00:00 (commit #ba308fc)
Author: Marwan Al-Soltany (MarwanAlsoltany@gmail.com) / Commiter: Marwan Al-Soltany (MarwanAlsoltany@gmail.com)
Update logger class * Refactor fallback path guessing when no path is specified.
-
2020-09-25T19:19:36+00:00 (commit #035aa93)
Author: Marwan Al-Soltany (MarwanAlsoltany@gmail.com) / Commiter: Marwan Al-Soltany (MarwanAlsoltany@gmail.com)
Update logger class * Refactor logger class to make use of the newly created utility class * Remove an internal method as it is provided now the utility class
-
2020-09-23T18:47:06+00:00 (commit #1a3f203)
Author: Marwan Al-Soltany (MarwanAlsoltany@gmail.com) / Commiter: Marwan Al-Soltany (MarwanAlsoltany@gmail.com)
Fix typos and update DocBlocks * Fix some typos in DockBlocks and other parts of the codebase * Add examples to classes DocBlocks
-
2020-09-13T22:04:52+00:00 (commit #a9dd405)
Author: Marwan Al-Soltany (MarwanAlsoltany@gmail.com) / Commiter: Marwan Al-Soltany (MarwanAlsoltany@gmail.com)
Update logger class * Refactor an internal method * Update class DocBlock
-
2020-06-23T00:50:44+00:00 (commit #e73b13f)
Author: Marwan Al-Soltany (MarwanAlsoltany@gmail.com) / Commiter: Marwan Al-Soltany (MarwanAlsoltany@gmail.com)
Fix logger class * Fix addtional line breaks when writing to log file
-
2020-06-13T05:59:31+00:00 (commit #26e55aa)
Author: Marwan Al-Soltany (MarwanAlsoltany@gmail.com) / Commiter: Marwan Al-Soltany (MarwanAlsoltany@gmail.com)
Add helper classes * Add Logger.php * Add Example.php