public void Load(ILua lua, bool is_serverside, ModuleAssemblyLoadContext assembly_context) { lua.PushGlobalTable(); lua.GetField(-1, "hook"); lua.GetField(-1, "Add"); lua.PushString("Tick"); lua.PushString(tickEventId); lua.PushManagedFunction(lua => { try { lua.Print("Test started"); Logger log1 = new LoggerConfiguration() .MinimumLevel.Verbose() .WriteTo.GmodSink() .CreateLogger(); string VerboseMessage1 = Guid.NewGuid().ToString(); string DebugMessage1 = Guid.NewGuid().ToString(); string InformationMessage1 = Guid.NewGuid().ToString(); string WarningMessage1 = Guid.NewGuid().ToString(); string ErrorMessage1 = Guid.NewGuid().ToString(); string FatalMessage1 = Guid.NewGuid().ToString(); string FatalWithExceptionMessage1 = Guid.NewGuid().ToString(); Exception FatalException1 = new Exception(Guid.NewGuid().ToString()); log1.Verbose(VerboseMessage1); log1.Debug(DebugMessage1); log1.Information(InformationMessage1); log1.Warning(WarningMessage1); log1.Error(ErrorMessage1); log1.Fatal(FatalMessage1); log1.Fatal(FatalException1, FatalWithExceptionMessage1); Logger log2 = new LoggerConfiguration() .MinimumLevel.Verbose() .WriteTo.GmodSink(restrictedToMinimumLevel: Serilog.Events.LogEventLevel.Warning) .CreateLogger(); string InformationMessage2 = Guid.NewGuid().ToString(); string WarningMessage2 = Guid.NewGuid().ToString(); string ErrorMessage2 = Guid.NewGuid().ToString(); log2.Information(InformationMessage2); log2.Warning(WarningMessage2); log2.Error(ErrorMessage2); Thread.Sleep(2000); FileStream fileStream = File.Open("garrysmod/console.log", FileMode.Open, FileAccess.Read, FileShare.ReadWrite); StreamReader streamReader = new StreamReader(fileStream); string console_log = streamReader.ReadToEnd(); if (!Regex.IsMatch(console_log, @$ "\[Verbose\].+{VerboseMessage1}\r{{0,1}}$", RegexOptions.ECMAScript | RegexOptions.Multiline | RegexOptions.Compiled)) { throw new Exception("Verbose message 1 test failed"); } if (!Regex.IsMatch(console_log, @$ "\[Debug\].+{DebugMessage1}\r{{0,1}}$", RegexOptions.ECMAScript | RegexOptions.Multiline | RegexOptions.Compiled)) { throw new Exception("Debug message 1 test failed"); } if (!Regex.IsMatch(console_log, @$ "\[Information\].+{InformationMessage1}\r{{0,1}}$", RegexOptions.ECMAScript | RegexOptions.Multiline | RegexOptions.Compiled)) { throw new Exception("Information message 1 test failed");