From a9aab628a23ed20391cb3efda07c85b0b779c526 Mon Sep 17 00:00:00 2001 From: Brian Feucht Date: Fri, 19 Jan 2024 13:33:25 -0800 Subject: [PATCH] Turn on debug dumping to get chromium logs --- .../SampleLambda-dotnet8/HelloWorldHandler.cs | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/sample/SampleLambda-dotnet8/HelloWorldHandler.cs b/sample/SampleLambda-dotnet8/HelloWorldHandler.cs index bfb162b..e2bc2b8 100644 --- a/sample/SampleLambda-dotnet8/HelloWorldHandler.cs +++ b/sample/SampleLambda-dotnet8/HelloWorldHandler.cs @@ -1,6 +1,7 @@ using Amazon.Lambda.Core; using HeadlessChromium.Puppeteer.Lambda.Dotnet; using Microsoft.Extensions.Logging; +using PuppeteerSharp; namespace SampleLambda { @@ -14,10 +15,24 @@ public async Task Handle(ILambdaContext context) var launchArgs = HeadlessChromiumPuppeteerLauncher.DefaultChromeArgs .Append("--enable-logging") - .Append("--v=1") + .Append("--log-level=0") + .Append("--single-process") .ToArray(); - await using (var browser = await browserLauncher.LaunchAsync(launchArgs)) + + var chromeLocation = new ChromiumExtractor(loggerFactory).ExtractChromium(); + + var launchOptions = new LaunchOptions() + { + ExecutablePath = chromeLocation, + Args = launchArgs, + Headless = true, + DumpIO = true, + EnqueueTransportMessages = false, + UserDataDir = "/tmp/", + }; + + await using (var browser = await new Launcher(loggerFactory).LaunchAsync(launchOptions)) await using (var page = await browser.NewPageAsync()) { await page.GoToAsync("https://www.google.com");