Download the PHP package germania-kg/logger without Composer

On this page you can find all versions of the php package germania-kg/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 logger


Germania KG · Logger

Default logging solution for our websites: Service Provider for Logging with Monolog 1 and 2.

Packagist PHP version Build Status Scrutinizer Code Quality Code Coverage Build Status

Installation with Composer

The major release 4 requires PHP 7.2+. The older release 3 supports Monolog 2.

Basics

Class LoggerServiceProvider is a Pimple ServiceProviderInterface and can be registered to any Pimple DI container (or array or \ArrayAccess). Its constructor requires the App or Logger name. – Optionally, the $_SERVER context may pe passed. An optional third parameter turns on IP address anonymizing:

Pimple is not required.

The service providers cope with Arrays and \ArrayAccess instances as well.

Work with an array as base for another, more modern DI container. The register method amends and returns the passed array:

Or pass another DI container which implements \ArrayAccess:

Services provided

This Monolog Logger instance is your PSR-3 Logger:

This Monolog Handlers array is empty per default; it will be filled by one or more of the specialised Service Providers below.

Unless you want to add other handlers than those configured by the specialised Service providers you won't need to use these.

This Monolog Processors array contains per default just Monolog's WebProcessor with ip, method and url extra context variables.

Unless you want to add other processors than those configured by the specialised Service providers you won't need to use these.

Adding processors to handlers

Monolog handlers are provided by Pimple services. Grab the handler instance and add another Monolog Processor by extending the service definition:

Specialised Service Providers

Log to Logfile

Class FileLoggerServiceProvider requires a logfile path. Optionally, you may pass a custom maximum number of logfiles (default: 30).

To set the loglevel, pass Monolog Loglevel constant or PSR-3 LogLevel (e.g. Monolog\Logger::DEBUG or \Psr\Log\LogLevel::INFO). Default is Monolog\Logger::DEBUG.

Retrieve the Monolog handler

This handler is an instance of \Monolog\Handler\RotatingFileHandler

Log to StdErr (stream)

Class StreamLoggerServiceProvider accepts optional parameters for an output stream (default: php://stderr) and a loglevel, either Monolog Loglevel constant or PSR-3 LogLevel (e.g. Monolog\Logger::DEBUG or \Psr\Log\LogLevel::INFO). Default is Monolog\Logger::DEBUG.

Retrieve the Monolog handler

This handler is an instance of \Monolog\Handler\StreamHandler

Log using SwiftMailer

This service requires service definitions for SwiftMailer and SwiftMailer.HtmlMessage. Germania KG's germania-kg/mailer will provide those.

Class SwiftMailerLoggerServiceProvider accepts optional parameters for outer log level and inner loglevel, both either Monolog Loglevel constant or PSR-3 LogLevel (e.g. Monolog\Logger::DEBUG or \Psr\Log\LogLevel::INFO).

The outer loglevel (default: Monolog\Logger::WARNING) will trigger Monolog's FingersCrossedHandler which in turn uses Monolog's BufferHandler to send an log messages digest using Monolog's SwiftMailerHandler. Any log message in the email sent will be of inner loglevel upwards (default: Monolog\Logger::DEBUG)

Retrieve the Monolog handler

Despite its name, the handler is actually an instance of Monolog\Handler\FingersCrossedHandler which wraps an instance of Monolog\Handler\BufferHandler which wraps an instance of Monolog\Handler\SwiftMailerHandler

Log using CLImate Logger

This requires CLImate, available with Composer: league/climate

Class ClimateLoggerServiceProvider requires a Monolog Loglevel constant or PSR-3 LogLevel (e.g. Monolog\Logger::DEBUG or \Psr\Log\LogLevel::INFO).

Retrieve the Monolog handler

N.B. This is actually a Monolog\Handler\PsrHandlerinstance which wraps a Climate Logger League\CLImate\Logger

Log using BrowserConsole Logger

Class BrowserConsoleLoggerServiceProvider optionally accepts a Monolog Loglevel constant or PSR-3 LogLevel (e.g. Monolog\Logger::DEBUG or \Psr\Log\LogLevel::INFO). If left out or set to null, logging to browser console will be skipped.

Retrieve the Monolog handler

The handler is an instance of Monolog\Handler\BrowserConsoleHandler

Log to Microsoft Teams

Sends nicely formatted log messages to Microsoft Teams using Monolog's HtmlFormatter.

This requires CMDISP's monolog-microsoft-teams package, available via Composer: cmdisp/monolog-microsoft-teams.

Class TeamsLoggerServiceProvider requires a Incoming Webhook URL string, and optionally a Monolog Loglevel constant or PSR-3 LogLevel (e.g. Monolog\Logger::DEBUG or \Psr\Log\LogLevel::INFO). Registering this ServiceProvider to a Pimple DI container will silently skip if the Webhook URL is empty.

Deprecation notice

Class Germania\Logger\HtmlFormattedTeamsLogHandler was an extension of the CMDISP\MonologMicrosoftTeams\TeamsLogHandler class and provided better log message formatting. As of the v1.1 release of CMDISP's monolog-microsoft-teams package, this extension is not needed any longer and will be removed as of major release 5.

Retrieve the Monolog handler

The handler is an instance of \CMDISP\MonologMicrosoftTeams\TeamsLogHandler

Log to Slack channel

Class SlackLoggerServiceProvider requires Slack token, channel, and username. It optionally accepts a Monolog Loglevel constant or PSR-3 LogLevel (e.g. Monolog\Logger::DEBUG or \Psr\Log\LogLevel::INFO).

For more information on using Slack as Logger, see these links:

Retrieve the Monolog handler

The handler is an instance of \Monolog\Handler\SlackHandler


Usage Example

Development and Unit tests

Either copy phpunit.xml.dist to phpunit.xml and adapt to your needs, or leave as is. Run PhpUnit test or composer scripts like this:


All versions of logger with dependencies

PHP Build Version
Package Version
Requires php Version ^7.2|^8.0
pimple/pimple Version ^3.0
psr/log Version ^1.0
monolog/monolog Version ^1.16|^2.0
bramus/monolog-colored-line-formatter Version ^2.0|^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 germania-kg/logger contains the following files

Loading the files please wait ....