In order to test using the provided docker-compose file, you'll need an up-to-date docker/docker-compose installation
You can start the Loki container by navigating to src/main/test/docker and running
docker-compose up -d
If you're testing from a local php installation, you'll need to retrieve the Loki container ip with :
docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' itspire-monolog-loki_loki_1
and replace the ip in the LOKI_ENTRYPOINT definition in phpunit.xml :
<env name="LOKI_ENTRYPOINT" value="http://172.17.0.1:7000/" />
If you're testing from containerized php not in the default docker bridge network,
you'll need to start the container with an extra host named Loki mapped to your current host ip,
using the following option :
--add-host loki:{the_ip_of_your_host_in_your_network}
Run the test using phpunit and you can verify that posting to Loki works
by running the following from your host terminal :
curl -G -s "http://localhost:7000/loki/api/v1/query" --data-urlencode 'query={channel="test"}' | jq
For each time you ran the tests, you should see a log entry looking like the following :
"stream": {
"channel": "test",
"host": "f2bbe48b0204",
"level_name": "WARNING"
"values": [
"1591627127000000000",
"{\"message\":\"test\",\"level\":300,\"level_name\":\"WARNING\",\"channel\":\"test\",\"datetime\":\"2020-06-08 14:38:47\",\"ctxt_data\":\"{\\\"stdClass\\\":[]}\",\"ctxt_foo\":\"34\"}"