Download the PHP package ricardoboss/php-seq without Composer

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

Unit Tests

php-seq

A PHP library for Seq HTTP ingestion.

Installation

Usage

Note

All events get flushed automatically when the loggers __destruct method is called (i.e. at latest when the runtime shuts down).

You can use the example project in the example folder to try different things out. It uses guzzlehttp/guzzle as its PSR implementations.

Configuration

The configuration is split up between the actual client, sending the requests and the logger gathering events and forwarding them to the client. This makes it possible to create multiple loggers with different contexts/minimum log levels using the same client. Also, it enables us to implement new clients for other interfaces in the future (see “Future Scope” below).

SeqHttpClientConfiguration

Parameter Type Default Description
$endpoint string - The endpoint to use. Must not be empty. Usually has the form "https://seq-host:5341/api/events/raw"
$apiKey string\|null null If your Seq instance requires authentication, you need to provide your API key here. If given, it must not be empty.
$maxRetries int 3 The number of tries before throwing an exception if sending the events fails. Exceptions implementing \Psr\Http\Client\NetworkExceptionInterface bypass this limit and are immediately rethrown.

SeqLoggerConfiguration

Parameter Type Default Description
$backlogLimit int 10 The amount of events to collect before sending a batch to the server. You can explicitly flush all buffered events using the flush method.
$globalContext array\|null null A key-value list that gets attached to all events logged using this logger.

Advanced usage

Message templates & context

Seq supports the message templates syntax. You can use it too using the context parameter:

Note

The context values will be converted to strings. If they aren't scalar or Stringable objects, they are encoded using json_encode.

Custom Seq events

Seq uses the CLEF format for HTTP ingestion, which is used by this library. For your convenience, you can directly access all the properties of the CLEF format using the SeqEvent class.

Just create a new instance and send it using the SeqLogger or encode it using json_encode:

Note that you still need to validate the event yourself if you create it that way. You can check the requirements from Seq here: Reified properties

Escaping of user properties using @ is done automatically when encoding the event to JSON.

Minimum log level

You can specify the minimum log level a logger will buffer and send to Seq using the $minimumLogLevel constructor parameter of the SeqLoggerConfiguration class:

This will allow only Warning or more critical events to be sent to Seq (like Error and Fatal).

You can also adjust the minimum log level of the logger at runtime:

Dynamic Level Control

Seq supports a scheme called "Dynamic Level Control", which allows the client to adjust its minimum log level based on what is configured for its API key.

php-seq also supports this and will adjust the minimum log level of each logger based on what Seq responds.

You can read up on Dynamic Level Control here on Seq's website or in this brief blog post by Nicholos Blumhardt.

Error handling

All exceptions thrown by this library implement the \RicardBoss\PhpSeq\Contract\SeqException interface. This makes it easy to catch any exception wrapped by this library.

Future Scope

The aim for this library is to provide simple logging for Seq in PHP and stay compatible with current PHP and Seq versions.

A possible addition for this library could be to use GELF instead of HTTP using the sockets extension, but this is not planned for now.

Contributing

Contributions in all forms are welcome! If you are missing a specific feature or something isn't working as expected, please create an issue on GitHub: create issue.

If you can, you are encouraged to create a pull request. Please make sure you add tests for the functionality you add/change and make sure they pass.

License

This project is licensed under the MIT license. For more information, see License.


All versions of php-seq with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2
psr/http-client Version ^1.0
psr/http-factory Version ^1.0
psr/log Version ^3.0
jetbrains/phpstorm-attributes 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 ricardoboss/php-seq contains the following files

Loading the files please wait ....