using Amazon.Lambda.Core; using classes; using MySql.Data.MySqlClient; //Summary //Log in local db and AWS //Summary namespace classes { public class Logger { MySqlConnection con; public Logger(MySqlConnection con) { this.con = con; } public void WriteLog(string strCognitoUuid, string txtQuery, string txtResponse, string strType) { int rows = 0; try { if (con.State == System.Data.ConnectionState.Closed) con.Open(); txtQuery = Helper.CleanInput(txtQuery); txtResponse = Helper.CleanInput(txtResponse); var stm = "INSERT INTO `log`(strCognitoUuid, txtQuery, txtResponse, strType) VALUES('" + strCognitoUuid + "', '" + txtQuery + "', '" + txtResponse + "', '" + strType + "')"; var cmd = new MySqlCommand(stm, con); rows = cmd.ExecuteNonQuery(); } catch { } } public void LogMessage(ILambdaContext ctx, string msg) { ctx.Logger.LogLine( string.Format("{0}:{1} - {2}", ctx.AwsRequestId, ctx.FunctionName, msg)); } } }