Metadata-Version: 2.1
Name: new-relic-logger-for-python
Version: 0.1.6
Summary: Push logs into New Relic using standard python logger asynchronously.
License: MIT
Author: Andrés Peñaloza
Author-email: andres.penaloza@xintec.cl
Requires-Python: >=3.7,<4.0
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Requires-Dist: newrelic (>=6.2.0,<7.0.0)
Requires-Dist: requests (>=2.25.1,<3.0.0)
Description-Content-Type: text/markdown

## New Relic APM Logger
This library enables the standard python logger to send its logs to New Relic using an async strategy.
Note: These logs are linked to the application only in the context of a web transaction. 

## Configuration
Configure the APM agent according to the [documentation](https://docs.newrelic.com/docs/agents/python-agent/installation/standard-python-agent-install/). A `newrelic.ini` should be generated.

To enable the python logging module, include this line in your file. 
```python
import newrelic_logger
```
### Arguments
NewRelicLogger constructor receives the following optional arguments:

|Name|Type|Description|
|---|---|---|
|app_id|int|The app id for the newrelic APM
|app_name|str|The app name for the newrelic APM
|license_key|str|The license_key for comunicating with the new relic api
|region|str|The region for newrelic, either "US" or "EU"
|log_level|ENUM|The numeric level of the logging event (one of DEBUG, INFO etc.)

### Environment Variables
Optionaly, some arguments can be configured by environment variables. These are:

|Name|Description|
|---|---|
|NEW_RELIC_APP_ID|The app id for the newrelic APM
|NEW_RELIC_APP_NAME|he app name for the newrelic APM
|NEW_RELIC_LICENSE_KEY|The license_key for comunicating with the new relic api
|NEW_RELIC_REGION|The region for newrelic, either "US" or "EU"

## Usage
Just use the normal python logger, for example, to send an info message:
```python
import logging
logging.info("This is an info message")
```

## Running the program
Run the application using the new relic agent either by using the admin script integration, or the manual integration, as mentioned in the [documentation](https://docs.newrelic.com/docs/agents/python-agent/installation/python-agent-advanced-integration/). For example, for the admin script:
```bash
NEW_RELIC_CONFIG_FILE=newrelic.ini newrelic-admin run-program YOUR_COMMAND_OPTIONS
```
and for the manual integration:
```python
import newrelic.agent
newrelic.agent.initialize('/some/path/newrelic.ini')
```
