Download the PHP package socarrat/logging without Composer

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

Socarrat\Logging

Robust logging library for every application.

Features

Installation

You can install this library through Packagist: composer require socarrat/logging.

Examples

You can find the output of this script examples/ directory.

Built-in loggers

The following loggers are shipped with this library under the namespace Socarrat\Logging\Loggers. You could also implement your own loggers; see the LoggingManager::addLogger.

FileLogger

Outputs logs into a file.

new FileLogger(\Closure $getFilePath)

Constructs a new file logger. You can pass a closure into the constructor, which is called on each log and returns the filename the log should be sent to. It receives two positional arguments: the LogLevel and the string to log.

You can replace the filepath getter later on by calling FileLogger::setFilePathGetter(\Closure $getFilePath).

NullLogger

This logger does nothing with the logs.

API

class Socarrat\Logging\LoggingManager

This is the central logging manager; you should use this to log things.

static public function addLogger(Logger $logger): int

Adds a logger instance to use. Returns the index which has been assigned to the logger. If multiple loggers have been set, each of them is called.

Parameter name Type Default value Description
$logger Logger - The logger instance to add.

static public function log(LogLevel $level, string $message)

Logs the given message at the given log level using the logger that has been set. If multiple loggers have been set, each of them is called.

Parameter name Type Default value Description
$level LogLevel - The level at which to log.
$message string - The log message.

static public function setMinimumLogLevel(LogLevel $level)

Sets the minimum log level. Log messages that have a lower level will not be logged.

Example: the minimum log level is LOG_NOTICE. Logs with LOG_DEBUG will not be logged, unlike LOG_ERROR logs.

Parameter name Type Default value Description
$level LogLevel - The minimum level at which to log.

abstract class Socarrat\Logging\Logger

This is the base class for loggers. All loggers should extend it.

abstract public function log(LogLevel $level, string $message)

Logs the given message at the given log level. You should not call this directly, use LogManager::log instead.

Parameter name Type Default value Description
$level LogLevel - The level at which to log.
$message string - The log message.

enum Socarrat\Logging\LogLevel: int

Contains the RFC 5424 log levels.

Log level Situation ID
LOG_EMERGENCY System is unusable. 2
LOG_ALERT Action must be taken immediately. 2
LOG_CRITICAL Critical conditions. 2
LOG_ERROR Error conditions. 3
LOG_WARNING Warning conditions. 4
LOG_NOTICE Notice: normal but significant conditions. 5
LOG_INFO Informational messages. 6
LOG_DEBUG Debug-level messages. 7

LogLevel::toString() will return the stringified version of the log level, e.g. calling (LogLevel::LOG_ALERT)->toString() will result in ALERT.

Copyright

(c) 2023 Romein van Buren. Licensed under the MIT license.

For the full copyright and license information, please view the license.md file that was distributed with this source code.


All versions of logging with dependencies

PHP Build Version
Package Version
No informations.
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 socarrat/logging contains the following files

Loading the files please wait ....