Skip to content

Instantly share code, notes, and snippets.

@guitarrapc
Created December 14, 2016 19:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save guitarrapc/32bd4c3a4745f0552408756cc5972111 to your computer and use it in GitHub Desktop.
Save guitarrapc/32bd4c3a4745f0552408756cc5972111 to your computer and use it in GitHub Desktop.
Local Context for .NET Core on Lambda Debugging
using System;
using Amazon.Lambda.Core;
namespace SimpleAsyncFunction
{
/// <summary>
/// Implementation for Local Debug
/// </summary>
public class LambdaContext : ILambdaContext
{
#region Implementation of ILambdaContext
public string AwsRequestId { get; }
public IClientContext ClientContext { get; }
public string FunctionName { get; } = typeof(LambdaContext).Namespace;
public string FunctionVersion { get; }
public ICognitoIdentity Identity { get; }
public string InvokedFunctionArn { get; }
public ILambdaLogger Logger { get; } = new CustomLambdaLogger();
public string LogGroupName { get; }
public string LogStreamName { get; }
public int MemoryLimitInMB { get; }
public TimeSpan RemainingTime { get; }
#endregion
}
/// <summary>
/// Implementation for Local Logger
/// </summary>
public class CustomLambdaLogger : ILambdaLogger
{
#region Implementation of ILambdaLogger
public void Log(string message)
{
Console.Write(message);
}
#endregion
#region Implementation of ILambdaLogger
public void LogLine(string message)
{
Console.WriteLine(message);
}
#endregion
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment