squill-logger
v1.0.3
Published
Custom logger send to SQS in TPP
Readme
SQuill – Serverless Logging via SQS
SQuill is a lightweight logging helper for AWS Lambda environments that sends structured logs to an SQS queue for centralized collection and processing. Built for plug-and-play use via Lambda Layers.
Installation
npm install squill-loggerFeatures
- Log any entity-related event with a simple function call
- Sends structured JSON messages to an SQS queue
- Automatically supports metadata and source tagging
- Can be imported via Lambda Layer or directly in your app
Usage
import { sendLogToSqs } from 'squill';
await sendLogToSqs({
entityType: 'ORDER',
entityId: 'abc-123',
type: 'ORDER_CREATED',
message: 'Order created successfully',
metadata: { amount: 500, currency: 'EUR' },
source: 'order-service', // optional
entityGroup: 'establishment-1' // optional
});Environment Variables
Ensure the following environment variables are defined in your Lambda function's configuration (not the layer itself):
| Variable | Description |
|----------|-------------|
| REGION | The AWS region your Lambda is running in |
| LOGGER_QUEUE_URL | The full SQS queue URL where logs should be sent |
These must be defined at the Lambda function level, not in the layer. Lambda Layers do not have their own environment — they inherit from the function that includes them.
Installation (via Lambda Layer)
- Upload your
squillcode as a Lambda Layer (e.g.,/opt/nodejs/squill.js). - In your Lambda function:
- Add the Layer ARN under "Layers"
- Add
REGIONandLOGGER_QUEUE_URLto your Lambda environment variables
- Import and use:
import { sendLogToSqs } from 'squill';
License
MIT – free to use and modify.
⚠️ About Environment Variables in Lambda Layers
Yes, as long as you set REGION and LOGGER_QUEUE_URL in the Lambda function, your sendLogToSqs function will access them just fine.
Lambda Layers do not isolate environment variables — they're just code libraries mounted under
/opt. Any code inside them will share the same runtime environment as the Lambda that invokes it.
