elixis/google-big-query-logger

Monolog handler to write and read log message to Google Big Query

1.0.0 2019-05-23 00:00 UTC

This package is auto-updated.

Last update: 2024-10-22 02:40:08 UTC


README

GoogleBigQuery-logger is PHP client, who extends a Monolog handler Monolog\Handler\AbstractProcessingHandler for writing logs in a BigQuery dataset making use of Google's google/cloud-bigquery PHP client.

Instalation

Google BigQuery logger will be available comming soon on Packagist and can be installed with Composer. Run this command:

composer require ...

Usage

Note: This first version of the Google BigQuery logger for PHP requires PHP 7.1 or greater.

Simple example to write logs.

<?php

require __DIR__ . '/vendor/autoload.php';

use GoogleBigQueryLogger\BigQueryLogger;
use GoogleBigQueryLogger\BigQueryTable;
use GoogleBigQueryLogger\Handler\BigQueryHandler;
use Monolog\Logger;

//Create a new table in a dataset
$bigQueryTable = new BigQueryTable();
$bigQueryTable->createTable();

// Create the logger
$logger = new Logger('logger');
// Add a new BigQuery handler
$logger->pushHandler(new BigQueryHandler($bigQueryTable));

// You can now use your logger
$logger->info('With only age');

Documentation

License

Monolog is licensed under the MIT License