Sends log messages to the Logentries log management service

Overview

Phalcon Logentries

Software License Build Status Total Downloads

Phalcon library to connect and make log entries using Logentries. You can adapt it to your own needs or improve it if you want.

Please write us if you have any feedback.

Thanks.

NOTE

The master branch will always contain the latest stable version. If you wish to check older versions or newer ones currently under development, please switch to the relevant branch.

Get Started

Requirements

To use this library on your machine, you need at least:

Development requirements:

Installation

Install composer in a common location or in your project:

$ curl -s http://getcomposer.org/installer | php

Create the composer.json file as follows:

{
    "require": {
        "phalcon/logentries": "~1.2"
    }
}

Run the composer installer:

$ php composer.phar install

Setup

When you have made your account on Logentries. Log in and create a new host with a name that best represents your app. Then, click on your new host and inside that, create a new log file with a name that represents what you are logging, example: myerrors. Bear in mind, these names are purely for your own benefit. Under source type, select Token TCP and click Register. You will notice a token appear beside the name of the log, these is a unique identifier that the logging library will use to access that logfile. You can copy and paste this now or later.

Then create adapter instance:

use Phalcon\Logger\Adapter\Logentries;

$di->set('logger', function() {
    $logger = new Logentries([
        'token' => getenv('LOGENTRIES_TOKEN'),
        // optional parameters
    ]);
    
    return $logger;
});

LOGENTRIES_TOKEN is the token we copied earlier from the Logentries UI. It associates that logger with the log file on Logentries.

Adding a Custom Host Name and Host ID sent in your PHP log events

To Set a custom host name that will appear in your PHP log events as Key / Value pairs pass to the Logentries::__constructor the following parameters:

  • host_name_enabled
  • host_name
  • host_id

For example:

use Phalcon\Logger\Adapter\Logentries;

$di->set('logger', function() {
    $logger = new Logentries([
        'token'             => getenv('LOGENTRIES_TOKEN'),
        'host_name_enabled' => true,
        'host_name'         => 'Custom_host_name_here',
        'host_id'           => 'Custom_ID_here_12345'
    ]);

    return $logger;
});

The host_name param can be left as an empty string, and the Logentries component will automatically attempt to assign a host name from your local host machine and use that as the custom host name.

To set a custom Host ID that will appear in your PHP log events as Key / Value pairs:

  • Enter a value instead of the empty string in host_id => '';
  • If no host_id is set and the empty string is left unaltered, no Host ID or Key / Value pairing will appear in your PHP logs.

Creating a Log

The example below shows how to create a log and add messages to it:

use Phalcon\Logger;
use Phalcon\Logger\Adapter\Logentries as LeAdapter;

$logger = new LeAdapter(['token' => 'ad43g-dfd34-df3ed-3d3d3']);

// These are the different log levels available:
$logger->critical('This is a critical message');
$logger->emergency('This is an emergency message');
$logger->debug('This is a debug message');
$logger->error('This is an error message');
$logger->info('This is an info message');
$logger->notice('This is a notice message');
$logger->warning('This is a warning message');
$logger->alert('This is an alert message');


// You can also use the log() method with a Logger constant:
$logger->log('This is another error message', Logger::ERROR);

// If no constant is given, DEBUG is assumed.
$logger->log('This is a message');

// Closes the logger
$logger->close();

Tests

Phosphorum use Codeception unit test.

First you need to re-generate base classes for all suites:

$ vendor/bin/codecept build

Execute all test with run command:

$ vendor/bin/codecept run
# OR
$ vendor/bin/codecept run --debug # Detailed output

More details about Console Commands see here.

License

Phalcon Logentries is open-sourced software licensed under the New BSD License. © Phalcon Framework Team and contributors

You might also like...
A simple PHP package for sending messages to Slack, with a focus on ease of use and elegant syntax.

Slack for PHP A simple PHP package for sending messages to Slack with incoming webhooks, focussed on ease-of-use and elegant syntax. Note: this packag

Make WhatsApp ChatBot and use WhatsApp API to send the WhatsApp messages in php .
Make WhatsApp ChatBot and use WhatsApp API to send the WhatsApp messages in php .

Ultramsg.com WhatsApp Bot using WhatsApp API and ultramsg Demo WhatsApp API ChatBot using Ultramsg API with php. Chatbot tasks: The output of the comm

The best announcer for PocketMine-MP 4.0 servers, make messages for your users very easily
The best announcer for PocketMine-MP 4.0 servers, make messages for your users very easily

BroadcastACM The best announcer for PocketMine-MP 4.0 servers, make messages for your users very easily. Make the best announcements for your server w

Easy management of Virtualization technologies including KVM, Xen, OpenVZ, Virtuozzo, and LXC/LXD including unified commands, monitoring, template management, and many more features.

ProVirted About Easy management of Virtualization technologies including KVM, Xen, OpenVZ, Virtuozzo, and LXC/LXD including unified commands, monitori

Magento extension which makes it impossible for a customer to log in until the account has been activated by the administrator.

This Magento 1 extension is orphaned, unsupported and no longer maintained. If you use it, you are effectively adopting the code for your own project.

Magento 2 module to log to Sentry
Magento 2 module to log to Sentry

Magento 2 Sentry Logger This Magento 2 module integrates the Sentry sdk into magento 2. Depending on the log level configured in the backend of magent

This tool can write the monolog standard log directly to clickhouse in real time via the tcp protocol

log2ck This tool can write the monolog standard log directly to clickhouse in real time via the tcp protocol. If you can write regular rules, other st

A set of PHP scripts which leverage MySQL INFORMATION_SCHEMA to create log tables and insert / update triggers

mysql-logtable-php mysql-logtable-php is a set of PHP scripts which leverage MySQL INFORMATION_SCHEMA to create log tables and insert / update trigger

Releases(v1.2.0)
Owner
Phalcon Orphanage
Some orphan or abandoned Phalcon packages we want to keep for some reason.
Phalcon Orphanage
An auto software that collects, scans and sends automatic instagram users

Instagram Advanced User Finder V1.0.0 With this PHP script, you can find users on Instagram and message them. Feedback Türkçe Get Key every week, you

Yasin 70 Jan 4, 2023
A fully-managed real-time messaging service that allows you to send and receive messages between independent applications.

A fully-managed real-time messaging service that allows you to send and receive messages between independent applications.

Google APIs 58 Dec 23, 2022
Tars is a high-performance RPC framework based on name service and Tars protocol, also integrated administration platform, and implemented hosting-service via flexible schedule.

TARS - A Linux Foundation Project TARS Foundation Official Website TARS Project Official Website WeChat Group: TARS01 WeChat Offical Account: TarsClou

THE TARS FOUNDATION PROJECTS 9.6k Jan 1, 2023
MOFHY Lite is a priceless MyOwnFreeHost Client Area for account management, ticket support system and a free ssl service

MOFHY Lite is a priceless MyOwnFreeHost Client Area for account management, ticket support system and a free ssl service. It has easy to use features much like the WHMCS Digit UI interface.

MOFHY Developers 1 Oct 21, 2022
jMQTT is a plugin for Jeedom aiming to connect Jeedom to an MQTT broker to subscribe and publish messages

jMQTT is a plugin for Jeedom aiming to connect Jeedom to an MQTT broker to subscribe and publish messages

null 19 Dec 27, 2022
PHP OOP interface for writing Slack Block Kit messages and modals

Slack Block Kit for PHP ?? For formatting messages and modals for Slack using their Block Kit syntax via an OOP interface ?? By Jeremy Lindblom (@jere

Slack PHP Framework 32 Dec 20, 2022
🍪 bakes cookies for PSR-7 messages

?? bakes cookies for PSR-7 messages

Hans Ott 35 Jul 13, 2022
An easy code to send messages on a discord text channel with webhook.

Status Webhook-Discord An easy code to send messages on a discord text channel with webhook. Don't forget to check the latest version of Webhook-Disco

Victor 1 Dec 3, 2021
Private groups to share messages, photos, videos, links with friends and family.

A truly private space for you and your friends What is Zusam ? Zusam (/tsuˈzam/) is a free and open-source way to self-host private forums for groups

Zusam 104 Dec 20, 2022
PHP-nats publisher - This is a simple package to publish messages to Nats

Nats publisher This is a simple package to publish messages to Nats Installation You can install the package using the Composer package manager. You c

Evert Jan Hakvoort 7 Oct 24, 2022