Download the PHP package arrowsphere/cloudwatch-logs without Composer

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

ArrowSphere CloudWatch Logs

This composer package allows to log data in CloudWatch, with auto-generated correlation id to follow the logs throughout all processes and their children.

⚙️ Installation

Install the latest version with

Request identifiers management

📖 Introduction

We manage 3 types of identifiers to help us identify our requests and follow their logs.

The request id, identified as ars-request-id, is the unique identifier for the current request. It is auto-generated and cannot be null.

The parent id, identified as ars-parent-id, is the identifier of the parent request, that directly called this one. It can be null if the current request is the originator of a process.

The correlation id, identified as ars-correlation-id, is the identifier of the originator request of the process.

Whenever an event is logged, we should have those 3 headers indicated in the logging context.

🔧 How to use

The header ids

The three header ids are automatically logged by the logger system provided by this package, however if you want to pass them through to other API calls, you'll have to access them by yourself.

You can access the headers by using class ArsHeaderManager.

The simplest way to use this class is to use static method ArsHeaderManager::initFromGlobals() with no argument, it works as a singleton, and will populate the ids with whatever is already present in the $_SERVER superglobal.

The $_SERVER superglobal will then contain all three ids (parent id being an empty string if there's none).

Here's an example of code to make use of the variables:

The logger

This package provides a monolog handler for CloudWatch. To use it you'll have to instanciate it with the following parameters:

The handler is now ready to be used, you can add it to your monolog logger with method pushHandler.

All logs you'll send to this logger will now be appended to CloudWatch, under the group name /{account_alias}/{stage}/{application}.

The logs are formatted by ArsJsonFormatter, which provides a unique format for ArrowSphere. This format is described here: https://confluence.arrowcloud.org/display/XSP/ArrowSphere+logs

This table is a reminder of the fields that can be used in the logs:

Name Mandatory Type Description
type yes string The level of the log entry, typically one of the eight RFC 5424 levels (DEBUG, INFO, NOTICE, WARNING, ERROR, CRITICAL, ALERT, EMERGENCY).
message yes string The message of the log entry, should be a short string describing what the entry is about. Additional context information can and should be included in the context field.
tags yes array of strings Any tags you might want to add in your log. To use the tags, include a tags field in the log context.
entries yes array This field is present for backward-compatibility reason with xBE but will not be used by this package so it will always be an empty array.
ars.correlation yes string The identifier that will be used between ArrowSphere calls to create a link between the various micro-services.
ars.request yes string The identifier of the current request.
ars.parent yes string The identifier of the request that directly called the current one, if available (otherwise it's just an empty string).
context no object This field is the context used in the log entry, and should contain all variable information you might want to add to make your log entry more useful. For simplicity, the extra field from the log entry is also included in the context.

Here's an example of log:

Please note that the logger uses ArsHeaderManager and provides the three header ids in the ars object as described above. This is handled by ArsHeaderProcessor.

📃 License

This package is made available under the MIT License (MIT). Please see License File for more information.


All versions of cloudwatch-logs with dependencies

PHP Build Version
Package Version
Requires php Version >=8.0
aws/aws-sdk-php Version ^3.304
monolog/monolog Version ^3.0
psr/log Version ^1.0 || ^2.0 || ^3.0
ramsey/uuid Version ^3.9 || ^4.2
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 arrowsphere/cloudwatch-logs contains the following files

Loading the files please wait ....