Created
December 14, 2016 19:07
-
-
Save guitarrapc/32bd4c3a4745f0552408756cc5972111 to your computer and use it in GitHub Desktop.
Local Context for .NET Core on Lambda Debugging
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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