Skip to content

Commit 4517391

Browse files
committed
support log level for docker container
1 parent 7b98c72 commit 4517391

3 files changed

Lines changed: 17 additions & 2 deletions

File tree

README.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,19 @@ php examples/run.php start
4141

4242
## Docker
4343

44+
Build and run from source:
45+
4446
```bash
4547
docker build --rm -t clickhouse-queue .
4648
docker run --name clickhouse-queue clickhouse-queue
4749
```
4850

51+
Run container with shared tmp directory:
52+
53+
```bash
54+
docker run -it -v /path/to/tmp:/var/www/clickhouse-queue/tmp --name clickhouse-queue pnixx/clickhouse-queue
55+
```
56+
4957
Environment variables:
5058
* `CLICKHOUSE_HOST` - ClickHouse host for inserts, default `localhost`
5159
* `CLICKHOUSE_PORT` - ClickHouse port for inserts, default `8123`
@@ -61,6 +69,7 @@ Environment variables:
6169
* `RABBIT_VHOST` - RabbitMQ vhost, default `/`
6270
* `MAX_DELAY` - time flush data to ClickHouse, default `5`
6371
* `MAX_FILE_SIZE` - max buffer size before flush to ClickHouse, default `5242880`
72+
* `LOG_LEVEL` - output log level, default `warning`
6473

6574
## Message structure
6675

@@ -87,7 +96,7 @@ Donations to this project are going directly to [PNixx](https://github.com/PNixx
8796
* BTC address: `1H3rhpf7WEF5JmMZ3PVFMQc7Hm29THgUfN`
8897
* ETH address: `0x6F094365A70fe7836A633d2eE80A1FA9758234d5`
8998
* XMR address: `42gP71qLB5M43RuDnrQ3vSJFFxis9Kw9VMURhpx9NLQRRwNvaZRjm2TFojAMC8Fk1BQhZNKyWhoyJSn5Ak9kppgZPjE17Zh`
90-
* TON address: `UQBt0-s1igIpJoEup0B1yAUkZ56rzbpruuAjNhQ26MVCaNlC`
99+
* TON address: `UQB5RntjBNMA6qXjuqTrl2TcqceNu3vMOj1AyyW3eeGGI-Qd`
91100

92101
## Contributing
93102

examples/run.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,12 @@
1111
require __DIR__ . '/../vendor/autoload.php';
1212

1313
// Create the logger
14+
$log_level = Level::Warning;
15+
if( getenv('LOG_LEVEL') ) {
16+
$log_level = Level::fromName(getenv('LOG_LEVEL'));
17+
}
1418
$logger = new Logger('Worker');
15-
$handler = new StreamHandler('php://output', Level::Warning);
19+
$handler = new StreamHandler('php://output', $log_level);
1620
$handler->setFormatter(new LineFormatter(null, null, true));
1721
$logger->pushHandler($handler);
1822

src/ClickhouseWorker.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<?php
22
namespace PNixx\Clickhouse;
33

4+
use Monolog\Level;
45
use Psr\Log\LoggerInterface;
56
use Revolt\EventLoop;
67
use Workerman\Stomp\Client;
@@ -259,6 +260,7 @@ private function stompConnect(): void {
259260
'passcode' => $this->config['stomp']['password'] ?? null ?: 'guest',
260261
'reconnect_period' => 1,
261262
'vhost' => $this->config['stomp']['vhost'] ?? null ?: '/',
263+
'debug' => $this->logger && method_exists($this->logger, 'isHandling') && $this->logger->isHandling(Level::Debug),
262264
]));
263265

264266
//Wait connection success

0 commit comments

Comments
 (0)