Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/efureev/loogger-driver-php

Loogger driver php
https://github.com/efureev/loogger-driver-php

Last synced: about 7 hours ago
JSON representation

Loogger driver php

Awesome Lists containing this project

README

        

# Loogger Notification Driver

## Description

PHP driver for `Loogger` service to send notifications to `Telegram`.

## Install

```bash
composer require efureev/loogger "^1.0"
```

## Use

### In your code:

```php
$looggerConfig = new Config($looggerConfigJson);
$loogger = new Loogger($looggerConfig);

$loogger->send($msg);
// ...
$loogger
->pattern("Gitlab: {{MSG}}")
->sendHTML("Hello from service");
```

A Message type format:

```php
$loogger
->asPlain() // send message as plain
// ->send('Text')
->asHTML() // send message as HTML
// ->send('Bold

code
')
->asMD() // send message as Markdown.
// ->send('*Bold* text')
```

Allowed variables for patterns and message:

- `MSG` - The Message content
- `SERVICE_NAME` - The service name
- `SERVICE_DESCRIPTION` - The service description
- `NOW` - The datetime. Format: `RFC822`
- `CHAT_ID` - The TG-chat ID
- `BR` - Return a cursor to the next line. Like a `\n`.
- `TAB` - Return a cursor to the next line. Like a `\t`.

### from console-file:

```shell
php send2loogger.php --msg='Testing message!'
```

**Arguments:**

* `--cnf=` - A full path to config file. Config file should be a JSON typed.
* `--msg=''` - A sending message
* `--debug` - Enables `debug mode`

### from curl:

```shell
curl --location --request POST 'https://loogger.mockery.dev/push' \
--header 'X-Token: $2a$10$du8TEzvOs6HTgrbkuuTl0JNnhGF2Ki3xLKuPG5LoGBcn4S91W' \
--data-raw 'Hello from service'
```

## Use Loogger service

Loogger is a service to send various notifications.
Nowdays, it has only one driver: `Telegram`.

The service located at `https://loogger.mockery.dev`.

To use the Loogger service you should register there through Telegram:

- Add tg-bot `@Loogger` to your group or direct chat to it.
- To register into Loogger:
_For person chat_: you should send auth data to it.
_For group chat_: nothing.
- Create a service: `/add`

A full list of commands you receive on `/help`