Download the PHP package serhii/tiny-logger without Composer

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

Tiny Logger Latest Stable Version Total Downloads License Minimum PHP Version

Lightweight composer package for file logging with ability to send errors with webhook.

Usage example

Set file path

For setting up the path globally for all the log files you can call setPath method in your bootstrap file.

NOTE: If you want to use logger in a cron scripts or something like WordPress hook, you need to call setPath() at the very first step of the script execution, it means that your project might have multiple places where you need to set path for your logs. If you don't want to call setPath() you can just pass the path to a tiny_log() function as a third argument. See an example in the Usage section.

Supported PHP versions

Usage

This package comes with a function tiny_log() where second and third arguments are not required.

You can also use Logger class if you want. It will do the same as using function.

`

Options

For using one of the available options you can optionally pass certain flag to tiny_log() function as the second argument. If you also need to pass error type just separate them with the pipe | character. See the example with option pos:

Available options

Send logs with POST request

Tiny logger allows you to send logs as a json object on a specific endpoint. To enable this option you need to call enablePostRequest method on Logger class. To disable POST request use disablePostRequest method.

Now if error occurs, json will be sent to http://my-site.com/webhook endpoint with POST request.

If you need to customize the json object structure, you can pass array as the second argument on enablePostRequest method.

Now you'll get json like this:

Each JsonFieldValue constant will be replaced with its value. For example JsonFieldValue::MESSAGE will be replaced with the error message. JsonFieldValue::TIMESTAMP will be replaced with error timestamp.

NOTE: If you want to use logger in a cron scripts or something like WordPress hook, you need to call enablePostRequest at the very first step of the script execution.

Get started

To install all php dependencies you need to have Composer PHP package manager installed on your machine. Then you need to run the command below in your root directory of the project.


All versions of tiny-logger with dependencies

PHP Build Version
Package Version
Requires php Version ^7.2|^8.0
ext-json Version *
ext-curl Version *
curl/curl Version ^2.3
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 serhii/tiny-logger contains the following files

Loading the files please wait ....