1. Go to this page and download the library: Download germania-kg/logger library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
germania-kg / logger example snippets
use Germania\Logger\LoggerServiceProvider;
// Have your Pimple or Slim3 Container at hand
$dic = new \Pimple\Container;
$dic->register( new LoggerServiceProvider( "My App" );
// Alternatively, pass custom server data environment,
// and/or disable IP address anonymization
$dic->register( new LoggerServiceProvider( "My App", $_SERVER, false ));
$dic = array();
$dic = (new LoggerServiceProvider( "My App" ))->register($dic)
$dic = new MyContainer();
(new LoggerServiceProvider( "My App" ))->register($dic);
use Psr\Log\LoggerInterface;
use Monolog\Logger as MonologLogger;
// These are equal and refer to the same instance:
$logger = $dic[LoggerInterface::class];
$logger = $dic[MonologLogger::class];
// Deprecated service names
$logger = $dic['Monolog.Psr3Logger'];
$logger = $dic['Logger'];
echo get_class($logger);
// Monolog\Logger
use Germania\Logger\FileLoggerServiceProvider;
// Use with Pimple
$dic = new \Pimple\Container();
$dic->register( new FileLoggerServiceProvider( "log/app.log" ));
$dic->register( new FileLoggerServiceProvider( "log/app.log", 30, \Monolog\Logger::DEBUG));
// Use with \ArrayAccess
$dic = new \Pimple\Container();
(new FileLoggerServiceProvider( "log/app.log" ))->register($dic);
// Use with array
$dic = array();
$dic = (new FileLoggerServiceProvider( "log/app.log" ))->register($dic);
use Germania\Logger\StreamLoggerServiceProvider;
// Use with Pimple
$dic = new \Pimple\Container();
$dic->register( new StreamLoggerServiceProvider );
$dic->register( new StreamLoggerServiceProvider("php://stderr", \Monolog\Logger::WARNING) );
// Use with \ArrayAccess
$dic = new \Pimple\Container();
(new StreamLoggerServiceProvider())->register($dic);
// Use with array
$dic = array();
$dic = (new StreamLoggerServiceProvider())->register($dic);
use Germania\Logger\SwiftMailerLoggerServiceProvider;
// Use with Pimple
$dic = new \Pimple\Container();
$dic->register( new SwiftMailerLoggerServiceProvider );
$dic->register( new SwiftMailerLoggerServiceProvider( \Monolog\Logger::WARNING ));
// Use with \ArrayAccess
$dic = new \Pimple\Container();
(new SwiftMailerLoggerServiceProvider)->register($dic);
// Use with array
$dic = array();
$dic = (new SwiftMailerLoggerServiceProvider)->register($dic);
use Germania\Logger\ClimateLoggerServiceProvider;
// Use with Pimple
$dic = new \Pimple\Container();
$dic->register( new ClimateLoggerServiceProvider( \Monolog\Logger::DEBUG ));
// Use with \ArrayAccess
$dic = new \Pimple\Container();
(new ClimateLoggerServiceProvider( \Monolog\Logger::DEBUG ))->register($dic);
// Use with array
$dic = array();
$dic = (new ClimateLoggerServiceProvider( \Monolog\Logger::DEBUG ))->register($dic);
use Germania\Logger\BrowserConsoleLoggerServiceProvider;
// Use with Pimple
$dic = new \Pimple\Container();
$dic->register( new BrowserConsoleLoggerServiceProvider );
$dic->register( new BrowserConsoleLoggerServiceProvider( \Monolog\Logger::INFO ));
// Use with \ArrayAccess
$dic = new \Pimple\Container();
(new ClimateLoggerServiceProvider)->register($dic);
// Use with array
$dic = array();
$dic = (new ClimateLoggerServiceProvider)->register($dic);
use Germania\Logger\TeamsLoggerServiceProvider;
use Monolog\Logger;
$incoming_webhook_url="https://outlook.office.com/webhook/many-many-letters";
// Use with Pimple
$dic = new \Pimple\Container();
$dic->register( new TeamsLoggerServiceProvider( $incoming_webhook_url ));
$dic->register( new TeamsLoggerServiceProvider( $incoming_webhook_url, \Monolog\Logger::NOTICE ));
// Use with \ArrayAccess
$dic = new \Pimple\Container();
(new TeamsLoggerServiceProvider( $incoming_webhook_url ))->register($dic);
// Use with array
$dic = array();
$dic = (new TeamsLoggerServiceProvider( $incoming_webhook_url ))->register($dic);
use Germania\Logger\SlackLoggerServiceProvider;
// Use with Pimple
$dic = new \Pimple\Container();
$dic->register( new SlackLoggerServiceProvider(
$slack_token,
$slack_channel,
$slack_username,
\Monolog\Logger::CRITICAL
));
// Use with \ArrayAccess
$dic = new \Pimple\Container();
(new SlackLoggerServiceProvider( ... ))->register($dic);
// Use with array
$dic = array();
$dic = (new SlackLoggerServiceProvider( ... ))->register($dic);
use Germania\Logger\LoggerServiceProvider;
use Germania\Logger\FileLoggerServiceProvider;
use Monolog\Logger as Monolog;
use Psr\Log\LoggerInterface;
use Psr\Log\LogLevel;
// 1. Basic setup: Pimple
$dic = new \Pimple\Container();
$log_name = "My App";
$anonymize_ip = true;
$server_data = $_SERVER;
$dic->register( new LoggerServiceProvider(
$log_name,
$server_data,
$anonymize_ip
));
// 2. The 'LoggerServiceProvider' alone won't do anything.
// So, adding a specialized Service Provider is needed:
$max_files_count = 30;
$dic->register( new FileLoggerServiceProvider("log/app.log", 30, Monolog::DEBUG ));
$dic->register( new FileLoggerServiceProvider("log/app.log", 30, LogLevel::DEBUG ));
// 3. Now you can grab your PSR-3 Logger:
$logger = $dic[LoggerInterface::class];
$logger->info("Hooray!");
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.