Download the PHP package activecollab/logger without Composer

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

Logger

Build Status

This package implements some of our internal conventions on top of PSR-3. Logger that it publishes is fully PSR-3 comptabile with some extra functionality (optional), as well as a factory that makes logger creation easy:

Once logger is set, you can use it like any other PSR-3 logger:

Special loggers are:

  1. Event logging using LoggerInterface::event() method. This will log a named event on info level, and set event context attribute to event name,
  2. Request summary logging using LoggerInterface::requestSummary() method. This will log some interesting request data, like executing time, total queries and query count etc.

Loggers

Packages comes with following backends implemented:

LoggerInterface::FILE - Log to files in log directory. Log directory is required as first logger argument when creating a logger:

Second argument is log file name, and it is optional. When skipped, system will log to log.txt file in the specified folder. Third argument is file permissions level. Default is 0644 when skipped, but you can specify any value (in octal notation).

Note that we set rotating file logging, where only past 7 days of logs are kept.

LoggerInterface::GRAYLOG - Log messages are sent to Graylog2 server using GELF formatter. Additional arguments are Graylog2 server host and port. If they are skipped, 127.0.0.1 and are used:

LoggerInterface::BLACKHOLE - Messages are not logged anywhere.

Message Buffering

Logger is built to buffer messages until request details are set (using setAppRequest() method). Reason why we delay writing to log is to be able to add request details to all messages, so we can connect the dots alter on:

If request is not set, buffer will not be flushed unless you flush it yourself, or register a shutdown function:

Application Details

This package always logs application name, version and environemnt. These arguments are required and they need to be provided to FactoryInterface::create() method, when creating new logger instance:

Environment arguments are sent as context arguments with all messages captured via logger instance. User can specify additional environment arguments, using FactoryInterface::setAdditionalEnvArguments() method:

Exception Serialization

When exceptions are passed as context arguments, package will "explode" them to a group of relevant arguments: message, file, line, code, and trace. Previous exception is also extracted, when available:

If you have special exceptions that collect more info than message, code, file, line, trace and previous, you can register a callback that will extract that data as well:

Callback gets three arguments:

  1. $argument_name - contenxt argument name under which we found the exception,
  2. $exception_name - exception itself,
  3. $context - access to resulting log message context arguments.

As with additional environment variables, exception serializers can be added to factory, and factory will pass it on to all loggers that it produces:

Error Handling

Logger comes equiped with a class that can register error and exception handlers and direct them to the log. Quick setup:

To restore error and exception handled, simply call restore() method:

Handler can be configured to do different things for diffent error levels. For example, you can configure it to throw an exception on PHP warning, or to silence an event all together:

By default, exceptions are logged and re-thrown. This behavior can be turned off:


All versions of logger with dependencies

PHP Build Version
Package Version
Requires php Version >=7.1
monolog/monolog Version ^1.17
psr/http-message Version ^1.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 activecollab/logger contains the following files

Loading the files please wait ....