Git Product home page Git Product logo

lambda-structured-logger's Introduction

Java CI with Maven Maven Central

Lambda Structured Logger

A simple opinionated structured logger for AWS Lambda

Purpose

To provide a simple and easy to use structured logger specifically for use with AWS Lambda.

Example Usage

The following example usage:

import net.sailes.lambda.logger.Logger;
import net.sailes.lambda.logger.LoggerFactory;

public class PaymentHandler implements RequestHandler<APIGatewayProxyRequestEvent, APIGatewayProxyResponseEvent> {
    
    public APIGatewayProxyResponseEvent handleRequest(APIGatewayProxyRequestEvent event, Context context) {
        Logger logger = LoggerFactory.getLogger();        
        logger.addContextKeys(context);
        logger.info("Collecting Payment");
        ...
    }
}

Produces a single line JSON formatted output (displayed in multi-line for readability)

{
   "timestamp":"2020-08-09T11:52:34.290Z",
   "service":"Payment Service",
   "message":"Collecting Payment",
   "coldStart":true,
   "functionName":"example-HelloWorldFunction-1P1Z6B39FLU73",
   "functionVersion":"1.0.0",
   "functionArn":"arn:aws:lambda:eu-west-1:012345678910:function:example-HelloWorldFunction-1P1Z6B39FLU73",
   "functionMemorySize":512,
   "functionRequestId":"899856cb-83d1-40d7-8611-9e78f15f32f4"
}

Maven

<dependency>
  <groupId>net.sailes</groupId>
  <artifactId>lambda-structured-logger</artifactId>
  <version>0.2.0</version>
</dependency>

Cold Start Tracking

To use the cold start tracking functionality please use the LoggerFactory.getLogger() method.

Additional Configuration

Environment Variables

Name Description Default
SERVICE_NAME Friendly name for your function service_undefined

lambda-structured-logger's People

Contributors

marksailes avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.