Show / Hide Table of Contents

Class LambdaSharpAppClient

The LambdaSharpAppClient class is used to sending logs, metrics, and events to the Lambdasharp App API.

Inheritance
System.Object
LambdaSharpAppClient
Implements
ILambdaSharpLogger
Namespace: LambdaSharp.App
Assembly: LambdaSharp.App.dll
Syntax
public sealed class LambdaSharpAppClient : ILambdaSharpLogger, IAsyncDisposable

Constructors

LambdaSharpAppClient(LambdaSharpAppConfig, HttpClient)

Initializes a new LambdaSharpAppClient instance.

Declaration
public LambdaSharpAppClient(LambdaSharpAppConfig config, HttpClient httpClient)
Parameters
Type Name Description
LambdaSharpAppConfig config

A LambdaSharpAppConfig instance.

System.Net.Http.HttpClient httpClient

A HttpClient instance.

Properties

DebugLoggingEnabled

The DebugLoggingEnabled property indicates if log statements using DEBUG are emitted.

Declaration
public bool DebugLoggingEnabled { get; }
Property Value
Type Description
System.Boolean

Boolean indicating if requests and responses are logged

ErrorReportGenerator

Retrieve the ErrorReportGenerator instance used to generate error reports.

Declaration
public ILambdaErrorReportGenerator ErrorReportGenerator { get; }
Property Value
Type Description
ILambdaErrorReportGenerator

The ErrorReportGenerator instance.

Info

The Info property return information about the LambdaSharp environment.

Declaration
public ILambdaSharpInfo Info { get; }
Property Value
Type Description
ILambdaSharpInfo

The ILambdaSharpInfo instance.

Methods

Log(LambdaLogLevel, Exception, String, Object[])

Log a message with the given severity level. The format string is used to create a unique signature for errors. Therefore, any error information that varies between occurrences should be provided in the arguments parameter.

Declaration
public void Log(LambdaLogLevel level, Exception exception, string format, params object[] arguments)
Parameters
Type Name Description
LambdaLogLevel level

The severity level of the log message. See LambdaLogLevel for a description of the severity levels.

System.Exception exception

Optional exception to log. The exception is logged with its description and stacktrace. This parameter can be null.

System.String format

Optional message to use instead of Exception.Message. This parameter can be null.

System.Object[] arguments

Optional arguments for the format parameter.

Remarks

Nothing is logged if both format and exception are null.

Log(LogLevel, Boolean, Exception, String, Object[])

Log a message with the given severity level. The format string is used to create a unique signature for errors. Therefore, any error information that varies between occurrences should be provided in the arguments parameter.

Declaration
public void Log(LogLevel logLevel, bool echo, Exception exception, string format, params object[] arguments)
Parameters
Type Name Description
Microsoft.Extensions.Logging.LogLevel logLevel

The severity level of the log message. See Microsoft.Extensions.Logging.LogLevel for a description of the severity levels.

System.Boolean echo

Echo log message to the browser console.

System.Exception exception

Optional exception to log. The exception is logged with its description and stacktrace. This parameter can be null.

System.String format

Optional message to use instead of Exception.Message. This parameter can be null.

System.Object[] arguments

Optional arguments for the format parameter.

Remarks

Nothing is logged if both format and exception are null.

LogEvent<T>(T, IEnumerable<String>)

Send a CloudWatch event with optional event details and resources it applies to. This event is forwarded to the configured EventBridge. The 'detail-type' property is set to the full type name of the detail value.

Declaration
public void LogEvent<T>(T detail, IEnumerable<string> resources = null)
Parameters
Type Name Description
T detail

Data-structure to serialize as a JSON string. If value is already a string, it is sent as-is. There is no other schema imposed. The data-structure may contain fields and nested subobjects.

System.Collections.Generic.IEnumerable<System.String> resources

Optional AWS or custom resources, identified by unique identifier (e.g. ARN), which the event primarily concerns. Any number, including zero, may be present.

Type Parameters
Name Description
T

LogException(Exception)

The LogException(Exception) method is only invoked when Lambda function ErrorReportGenerator instance has not yet been initialized of if an exception occurred while invoking LogRecord(ALambdaLogRecord).

Declaration
public void LogException(Exception exception)
Parameters
Type Name Description
System.Exception exception

Exception to record.

LogRecord(ALambdaLogRecord)

Log a ALambdaLogRecord record instance.

Declaration
public void LogRecord(ALambdaLogRecord record)
Parameters
Type Name Description
ALambdaLogRecord record

The record to log.

Implements

ILambdaSharpLogger
In This Article
Back to top Generated by DocFX