Download the PHP package marck-devs/simple-logger without Composer

On this page you can find all versions of the php package marck-devs/simple-logger. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package simple-logger

Simple logger for php

Install

Install via composer:

Usage

LogLevels

This class contains all levels available for the logger:

Also have static method to parse string and get the corresponding level:

With this method you can read the log level from .env or config file and load into logger.

SimpleLogger

This is the main class.

Method: public function __construct($name, $level, $date_format, $log_format)


public function log($msg, $data=[])

public function info($msg, $data=[])

public function debug($msg, $data=[])

public function warn($msg, $data=[])

public function error($msg, $data=[])

public function critical($msg, $data=[])

Write a line in the default output stream whit the passed message. This message can be formatted as python format function. In the message can put any key into braces and generate the array as dictionary whit the key and the value:

There are same reserved keywords:

If want a personal format for logger, you can create a class that implements LogFormatter.

Save into log files

The SimpleLogger has two method to set the logs file and the errors file:

With this the default output stream will change to the files.

Make custom formatter

The log formatter set the way to print the log line into the main output stream. To create custom, you will need to implement the LogFormatter interface.

When you have your custon formatter you can set to the logger via static method or constructor:

In both case the formatter is set globally.

Formating the date

The default format for date is the Spanish format: d-m-Y H:i:s, but this can be change to custom format creatin an implementation from DateFormatter interface.

To set to the logger, like before, you can set in the constructor or with the static method:

Set Log level

To set the log level for the logger we have the static method set_log_level(int) It need a LogLevel constant.

File paths

When visualize the file path whit the {file} option, dont show full path, only the file name and same parent dir. The number of parent can be change by setting in the static method set_dir_level(int). If is set 2 levels, only will show 2 dir parents.


All versions of simple-logger with dependencies

PHP Build Version
Package Version
Requires php Version >=7.3.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package marck-devs/simple-logger contains the following files

Loading the files please wait ....