Skip to content

Commit 35df0c1

Browse files
committed
refactor: improve logging format in getAirportCodeForCity function
1 parent f16b932 commit 35df0c1

File tree

1 file changed

+2
-12
lines changed
  • examples/Event Handler/BedrockAgentFunction/src

1 file changed

+2
-12
lines changed

examples/Event Handler/BedrockAgentFunction/src/Function.cs

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,24 +18,14 @@
1818

1919
resolver.Tool("getAirportCodeForCity", "Get airport code and full name for a specific city", (string city, ILambdaContext context) =>
2020
{
21-
logger.LogInformation($"Getting airport code for city: {city}");
21+
logger.LogInformation("Getting airport code for city: {City}", city);
2222
var airportService = new AirportService();
2323
var airportInfo = airportService.GetAirportInfoForCity(city);
2424

25-
logger.LogInformation($"Airport for {city}: {airportInfo.Code} - {airportInfo.Name}");
25+
logger.LogInformation("Airport for {City}: {AirportInfoCode} - {AirportInfoName}", city, airportInfo.Code, airportInfo.Name);
2626

2727
// Note: Best approach is to override the ToString method in the AirportInfo class
28-
// public override string ToString()
29-
// {
30-
// return $"{Name} ({Code}) in {City}";
31-
// }
32-
// This will return a string with properties Code and Name
3328
return airportInfo;
34-
35-
//Alternatively, you can return an anonymous object
36-
// return new {
37-
// airportInfo
38-
// };
3929
});
4030

4131

0 commit comments

Comments
 (0)