Skip to content

Commit

Permalink
add docs
Browse files Browse the repository at this point in the history
  • Loading branch information
nagi1 committed Sep 8, 2024
1 parent 1338dd6 commit 90c3d01
Show file tree
Hide file tree
Showing 2 changed files with 104 additions and 22 deletions.
124 changes: 103 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,39 @@
# This is my package laravel-newrelic-log-api
# New Relic Log API for Laravel

[![Latest Version on Packagist](https://img.shields.io/packagist/v/nagi/laravel-newrelic-log-api.svg?style=flat-square)](https://packagist.org/packages/nagi/laravel-newrelic-log-api)
[![GitHub Tests Action Status](https://img.shields.io/github/actions/workflow/status/nagi/laravel-newrelic-log-api/run-tests.yml?branch=main&label=tests&style=flat-square)](/~https://github.com/nagi/laravel-newrelic-log-api/actions?query=workflow%3Arun-tests+branch%3Amain)
[![GitHub Code Style Action Status](https://img.shields.io/github/actions/workflow/status/nagi/laravel-newrelic-log-api/fix-php-code-style-issues.yml?branch=main&label=code%20style&style=flat-square)](/~https://github.com/nagi/laravel-newrelic-log-api/actions?query=workflow%3A"Fix+PHP+code+style+issues"+branch%3Amain)
[![Total Downloads](https://img.shields.io/packagist/dt/nagi/laravel-newrelic-log-api.svg?style=flat-square)](https://packagist.org/packages/nagi/laravel-newrelic-log-api)

This is where your description should go. Limit it to a paragraph or two. Consider adding a small example.
Integrate New Relic Log API with Laravel your laravel application.

## Support us
```php
// in loggin.php
'stack' => [
'driver' => 'stack',
'channels' => ['single', 'newrelic-log-api'],
'ignore_exceptions' => false,
],

//...
'newrelic-log-api' => [
'driver' => 'monolog',
'handler' => \Nagi\LaravelNewrelicLogApi\LaravelNewrelicLogApi::logHandler(),
'level' => 'debug',
],
```

[<img src="https://github-ads.s3.eu-central-1.amazonaws.com/laravel-newrelic-log-api.jpg?t=1" width="419px" />](https://spatie.be/github-ad-click/laravel-newrelic-log-api)
```php
logger('newrelic-log-api')->info('Hey Mom!');

// or if you are using stack

logger()->info('Hey Mom!');
```

We invest a lot of resources into creating [best in class open source packages](https://spatie.be/open-source). You can support us by [buying one of our paid products](https://spatie.be/open-source/support-us).
## Support us

We highly appreciate you sending us a postcard from your hometown, mentioning which of our package(s) you are using. You'll find our address on [our contact page](https://spatie.be/about-us). We publish all received postcards on [our virtual postcard wall](https://spatie.be/open-source/postcards).
Does your business depend on our contributions? Reach out and support us on [Email](mailto:ahmedflnagi@gmail.com). All pledges will be dedicated to allocating workforce on maintenance and new awesome stuff.

## Installation

Expand All @@ -23,13 +43,6 @@ You can install the package via composer:
composer require nagi/laravel-newrelic-log-api
```

You can publish and run the migrations with:

```bash
php artisan vendor:publish --tag="laravel-newrelic-log-api-migrations"
php artisan migrate
```

You can publish the config file with:

```bash
Expand All @@ -40,20 +53,89 @@ This is the contents of the published config file:

```php
return [
'enabled' => env('NEWRELIC_ENABLED', false),

/**
* New Relic API key or License key
*
* @see https://docs.newrelic.com/docs/logs/log-api/introduction-log-api/#setup
*/
'api_key' => env('NEWRELIC_API_KEY'),

/**
* The base URL for the new relic log API
*
* @see https://docs.newrelic.com/docs/logs/log-api/introduction-log-api/#endpoint
*/
'base_url' => env('NEWRELIC_BASE_URL', 'https://log-api.eu.newrelic.com'),

/**
* The minimum logging level at which this handler will be triggered
*/
'level' => env('NEWRELIC_LEVEL', 'debug'),

/**
* Retry sending the log to New Relic API
*/
'retry' => env('NEWRELIC_RETRY', 3),

/**
* Delay between retries in milliseconds
*/
'retry_delay' => env('NEWRELIC_RETRY_DELAY', 1000),

/**
* Queue name to use for sending logs to New Relic API
*/
'queue' => env('NEWRELIC_QUEUE', env('QUEUE_CONNECTION')),

/**
* Log handler to use for sending logs to New Relic API
*/
'log_handler' => \Nagi\LaravelNewrelicLogApi\NewrelicLogHandler::class,
];

```

## Usage

### Get your newrelic License/API

### Add env values in your .env

```
NEWRELIC_ENABLED=true
NEWRELIC_API_KEY=<your_key>
Optionally, you can publish the views using
# if your account is not EU change the baseurl
# https://log-api.newrelic.com/log/v1
NEWRELIC_BASE_URL=https://log-api.eu.newrelic.com
```bash
php artisan vendor:publish --tag="laravel-newrelic-log-api-views"
```

## Usage
### Add new relic driver to your config

In your `logging.php` add `new-relic-log-api` driver

```php
'newrelic-log-api' => [
'driver' => 'monolog',
'handler' => \Nagi\LaravelNewrelicLogApi\LaravelNewrelicLogApi::logHandler(),
'level' => env('NEWRELIC_LEVEL', 'debug')
],

```

### Add it to your logging stack

in `logging.php`

```php
$laravelNewrelicLogApi = new Nagi\LaravelNewrelicLogApi();
echo $laravelNewrelicLogApi->echoPhrase('Hello, Nagi!');
'stack' => [
'driver' => 'stack',
'channels' => ['single', 'newrelic-log-api'],
'ignore_exceptions' => false,
],
```

## Testing
Expand All @@ -76,8 +158,8 @@ Please review [our security policy](../../security/policy) on how to report secu

## Credits

- [Ahmed Nagi](/~https://github.com/nagi1)
- [All Contributors](../../contributors)
- [Ahmed Nagi](/~https://github.com/nagi1)
- [All Contributors](../../contributors)

## License

Expand Down
2 changes: 1 addition & 1 deletion config/newrelic-log-api.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
/**
* The minimum logging level at which this handler will be triggered
*/
'level' => env('NEWRELIC_LEVEL', 'debug'),
'level' => env('NEWRELIC_LEVEL', env('LOG_LEVEL')),

/**
* Retry sending the log to New Relic API
Expand Down

0 comments on commit 90c3d01

Please sign in to comment.