Download the PHP package phpro/mage2-module-logger-handler without Composer

On this page you can find all versions of the php package phpro/mage2-module-logger-handler. 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 mage2-module-logger-handler

Logger Handler for Magento 2

This module allows you to easily configure custom log files. Especially useful when building several integrations, each requiring a separate log file.

Installation

composer require phpro/mage2-module-logger-handler

How to use

This module is only a basic building block. You can build on top of this to create custom log files in your projects. Below you can find an example implementation.

Stores configuration

To use a custom log file, you can add the following to the system config. This module also provides a source model for the log levels.

<!-- system.xml -->
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Config:etc/system_file.xsd">
    <system>
        <section id="module" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="1">
            <group id="log_type" translate="label" sortOrder="20" showInDefault="1">
                <field id="log_file_name" translate="label" type="text" sortOrder="10" showInDefault="1">
                    <label>Log File Name</label>
                </field>
                <field id="log_level" translate="label" type="select" sortOrder="20" showInDefault="1">
                    <label>Log Level</label>
                    <source_model>Phpro\LoggerHandler\Config\LogLevelsSource</source_model> <!-- Custom source model which is available in this module -->
                </field>
            </group>
        </section>
    </system>
</config>

Configuration class

You will need to create a Configuration class which implements the LogConfiguration interface. This Configuration class will be used by the Logger Handler.

This is an example of a Configuration class which uses the stores configuration defined above.

<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
    <virtualType name="[vendor_module_logtype]_logger_handler" type="Phpro\LoggerHandler\Logger\Handler">
        <arguments>
            <argument name="config" xsi:type="object">Vendor\Module\Config\SystemConfiguration</argument> <!-- Configuration class created above -->
        </arguments>
    </virtualType>
    <virtualType name="[vendor_module_logtype]_logger" type="Monolog\Logger">
        <arguments>
            <argument name="name" xsi:type="string">[module-logtype]-logger</argument> <!-- channel name; will also show in log files -->
            <argument name="handlers" xsi:type="array">
                <item name="stream" xsi:type="object">[vendor_module_logtype]_logger_handler</item> <!-- refers to the logger handler VirtualType -->
            </argument>
        </arguments>
    </virtualType>

    <!-- inject custom logger in service class -->
    <type name="Vendor\Module\Service\DoSomething">
        <arguments>
            <argument name="logger" xsi:type="object">[vendor_module_logtype]_logger</argument> <!-- refers to the logger VirtualType -->
        </arguments>
    </type>
</config>

All versions of mage2-module-logger-handler with dependencies

PHP Build Version
Package Version
Requires php Version ^7.0|^8.1
magento/framework Version ^100.1.7|^101.0.1|^102.0|^103.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 phpro/mage2-module-logger-handler contains the following files

Loading the files please wait ....