PHPackages                             mosetek/logger - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Logging &amp; Monitoring](/categories/logging)
4. /
5. mosetek/logger

ActiveLibrary[Logging &amp; Monitoring](/categories/logging)

mosetek/logger
==============

Simple interface for information and errors logging

1.1.4(5y ago)2565MITPHPPHP ^7.1

Since Sep 4Pushed 5y ago1 watchersCompare

[ Source](https://github.com/mateusz-osetek/php-logger)[ Packagist](https://packagist.org/packages/mosetek/logger)[ Docs](https://github.com/mateusz-osetek/php-logger)[ RSS](/packages/mosetek-logger/feed)WikiDiscussions master Synced 6d ago

READMEChangelog (2)Dependencies (1)Versions (6)Used By (0)

Simple PHP Logger 1.1.3
-----------------------

[](#simple-php-logger-113)

### Requirements

[](#requirements)

- PHP &gt;= 7.1
- PHPMailer &gt;= 6.0

---

### Installation

[](#installation)

Download it manually from GitHub or by composer: `composer require mosetek/logger:dev-master`

---

### Usage

[](#usage)

**Initializing the logger**
If you want to initialize logger with default path and filename (`logs/.log`) just use:

```
$logger = new Logger();
```

If you want to initialize logger on another path with another filename you can do this by defining those while creating new object.

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

Also you can initialize logger with custom date format as the last parameter. Logger's using the [standard PHP date() formats](https://www.php.net/manual/en/function.date.php).

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

**Another path and filename options**
You can get path, full path to file, filename or date format any time you need:

```
$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
```

You can also set another filename or path:

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

**Write and read files**
To put some content into file (defined in object creation) simply use `log()` method. You can log into file text, numbers and more complicated data structures like arrays and objects

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

You can also put some information into file, with some label next to it by adding information level as second parameter;

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

There are three supported labels for information leveling:

```
1 => [INFO]
2 => [DEBUG]
3 => [WARNING]
4 => [ERROR]
5 => [FATAL]
6 => [TRACE]

```

If you want to put data on different path you can declare it in third argument:

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

You can also put simple text without any date or special characters into your file by using `text()` method.

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

`text()` allows you to specify ending of line or text by adding additional param like that:

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

If you want to read contents of your log file use `read($path): string`.

```
$logger->read();
```

You can also read content of any other text files by adding a path parameter to read method.

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

**Putting variables into log file (deprecated: use log() instead)**
You can put more complicated structures like variables into log file by using this:

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

**Send file by email (deprecated)**
You can send your log file by email use `send($to)`. Method will grab contents of your log file and send it as message of email.

```
$logger->send('somebody@email.com');
```

Your server must support `sendmail` to use the above. If you're using UNIX-like systems please take care of installing [postfix](http://www.postfix.org).

**Move and copy files**

You can move your file to another destination.

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

If you want to move another file than active log file use second argument to point what other file you want to move.

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

If you want to just copy file some place else use `copy()` method:

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

And similar to the `move` method you can point another file to copy, if you don't want to copy your current log file.

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

**Wiping and deleting log file**
If you want to empty content of your current file use:

```
$logger->wipe();
```

You can also wipe any other text file by using `$path` parameter:

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

Interface allows you to deleting files by using `drop()` method.

```
$logger->drop();
```

Of course you can determine path to another file to drop as well

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

**Checking size of file**
You can check the size of a file by using below:

```
$logger->getFilesize();
```

Method by default returns size in megabytes. You can determine another unit by passing argument.

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

If you want you can check size of any other file by passing path in second argument:

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

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity16

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity57

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~125 days

Total

4

Last Release

2071d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/0924798d595dd49ab4196f786b32c5e220e87def85d08961b3b2c9d3936c0313?d=identicon)[mosetek](/maintainers/mosetek)

---

Top Contributors

[![mateusz-osetek](https://avatars.githubusercontent.com/u/45557562?v=4)](https://github.com/mateusz-osetek "mateusz-osetek (16 commits)")

---

Tags

composercomposer-librarycomposer-packageerror-logerror-loggererror-loggingerrorserrorslogfilefilesfilesysteminterfacelibrarylogloggerlogginglogsphptextuniversal-loggerlogphpfilesystemloggerphp-loggeruniversal logger

### Embed Badge

![Health badge](/badges/mosetek-logger/health.svg)

```
[![Health](https://phpackages.com/badges/mosetek-logger/health.svg)](https://phpackages.com/packages/mosetek-logger)
```

###  Alternatives

[logtail/monolog-logtail

Logtail handler for Monolog

233.2M3](/packages/logtail-monolog-logtail)[opengento/module-webapi-logger

This module allows you to analyze all the webapi rest done call toward your Magento.

1014.9k](/packages/opengento-module-webapi-logger)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
