/// <summary> /// /// </summary> /// <param name="args"></param> public static void Main(string[] args) { SerilogLog.Logger = new LoggerConfiguration() .MinimumLevel.ControlledBy(LevelSwitch) .MinimumLevel.Override("Microsoft", LogEventLevel.Information) .MinimumLevel.Override("System", LogEventLevel.Warning) .MinimumLevel.Override("Microsoft.EntityFrameworkCore", LogEventLevel.Warning) .Enrich.FromLogContext() .WriteTo.Console() .CreateLogger(); try { CreateWebHostBuilder(args) .Build() .Run(); SerilogLog.Information("Start the web host!"); } catch (System.Exception exp) { SerilogLog.Fatal(exp, "Host terminated unexpectedly"); } finally { SerilogLog.Information("Ending the web host!"); SerilogLog.CloseAndFlush(); } }
public static int Main(string[] args) { SLog.Logger = new LoggerConfiguration() .MinimumLevel.Information() .MinimumLevel.Override("Microsoft", LogEventLevel.Warning) .Enrich.FromLogContext() .WriteTo.Console() .WriteTo.File("logs/log.txt", rollingInterval: RollingInterval.Day) .CreateLogger(); try { SLog.Information("Starting web host"); CreateHostBuilder(args).Build().Run(); return(0); } catch (Exception ex) { SLog.Fatal(ex, "Host terminated unexpectedly"); return(1); } finally { SLog.CloseAndFlush(); } }
static void Main(string[] args) { if (args == null) { throw new ArgumentNullException(nameof(args)); } var mycfg = InitialSetup(); var dic = new CloudDictionary <string, string>("RoutersOnusOrense"); var crfConnection = GetMikrotikConnection(mycfg.CrfIp, mycfg.CrfUser, mycfg.CrfPass); var bridgeHostReader = crfConnection.CreateEntityReader <BridgeHost>(); var neighReader = crfConnection.CreateEntityReader <IpNeighbor>(); var ponHostsMacs = bridgeHostReader.GetAll().Where(h => h.OnInterface.Equals(mycfg.CrfOltInterface)); var crfNeighbors = neighReader.GetAll().Where(b => b.Interface.Equals(mycfg.CrfOltBridge)); var hostsToCheck = new List <string>(); foreach (var host in ponHostsMacs) { var crfNeigh = crfNeighbors.FirstOrDefault(m => m.MacAddress.Equals(host.MacAddress)); if (crfNeigh?.Address4 != null && !crfNeigh.Address4.Contains("10.")) { hostsToCheck.Add(crfNeigh.Address4); } } Log.Information("La cantidad de hosts es {cantidadHosts}", hostsToCheck.Count); foreach (var host in hostsToCheck) { if (dic.ContainsKey(host)) { Log.Information("La {ip} ya existe en el diccionario", host); } else { var routerConnection = GetMikrotikConnection(host, mycfg.RouterUser, mycfg.RouterPass); if (routerConnection == null) { continue; } var routerBridgeHostReader = routerConnection.CreateEntityReader <BridgeHost>(); var ponMac = routerBridgeHostReader.Get(h => h.MacAddress.StartsWith("E0:67")); if (ponMac != null) { dic.Add(host, ponMac.MacAddress); Log.Information("Agregada al diccionario la IP {ip} con la onu {onumac}", host, ponMac.MacAddress); } routerConnection.Close(); } } //Mostrar y contar todos los elementos del diccionario persistente //var count = 0; //foreach (var word in dic) //{ // Log.Information("Cliente : {hostIp} Onu : {onuMac}", word.Key, word.Value); // count++; //} //Log.Information("Cantidad de elementos en el diccionario {countdic}", count); //Console.ReadKey(); }
public async static Task Main(string[] args) { SerilogLog.Logger = new LoggerConfiguration() .MinimumLevel.ControlledBy(LevelSwitch) .MinimumLevel.Override("Microsoft", LogEventLevel.Information) .MinimumLevel.Override("System", LogEventLevel.Warning) .MinimumLevel.Override("Microsoft.EntityFrameworkCore", LogEventLevel.Warning) .Enrich.FromLogContext() .WriteTo.Console() .WriteTo.File( "logs/log.txt", outputTemplate: "{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz} [{Level:u3}] {Message:lj}{NewLine}{Exception}", rollingInterval: RollingInterval.Day, retainedFileCountLimit: 7, rollOnFileSizeLimit: true, shared: true) .CreateLogger(); try { var host = CreateHostBuilder(args).Build(); using (var scope = host.Services.CreateScope()) { var services = scope.ServiceProvider; try { var context = services.GetRequiredService <ApplicationDbContext>(); context.Database.Migrate(); var userManager = services.GetRequiredService <UserManager <ApplicationUser> >(); await ApplicationDbContextSeed.SeedDefaultUserAsync(userManager); await ApplicationDbContextSeed.SeedSampleDataAsync(context); } catch (Exception exp) { SerilogLog.Error(exp, "An error occurred while migrating or seeding the database."); } } await host.RunAsync(); } catch (System.Exception exp) { SerilogLog.Fatal(exp, "Host terminated unexpectedly"); } finally { SerilogLog.Information("Ending the web host!"); SerilogLog.CloseAndFlush(); } }
private FSharpOption <int> ConfigureMaxDocuments() { if (_maxDocuments.HasValue) { Log.Information("Processing {leaseId} in {auxContainerName} with max {changeFeedMaxDocuments} documents (<= {maxPending} pending) using {dop} processors", _leaseId, _aux.container, _maxDocuments.Value, MaxReadAhead, MaxConcurrentStreams); return(FSharpOption <int> .Some(_maxDocuments.Value)); } Log.Information("Processing {leaseId} in {auxContainerName} without document count limit (<= {maxPending} pending) using {dop} processors", _leaseId, _aux.container, MaxReadAhead, MaxConcurrentStreams); return(FSharpOption <int> .None); }
private async void StartGame() { try { if (PopupNavigation.Instance.PopupStack.Any()) { await PopupNavigation.Instance.PopAsync(); } } catch { Log.Information("JoinGamePage.StartGame: Tried to pop popup, but no popup popped"); } }
private async void Cancelled(object sender, EventArgs e) { Log.Information("EventArgs e for VisibleInvitations.CollectionChanged: {Newline}{e}", e); // If another game was cancelled, we don't care. If one of two overlapping invites // from the same host disappeared, we also don't care. if (controller.VisibleInvitations.Contains(invite)) { return; } WindowLabel.Text = "Game cancelled!"; Button.Text = "OK"; ActivityIndicator.IsVisible = false; await Task.Delay(4000); if (PopupNavigation.Instance.PopupStack.Contains(this)) { CancelClicked(sender, e); } }
public static void ConfigureLogging() { var date = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); var logFile = Path.Combine("logs", $"log-itinero-{date}.txt"); Log.Logger = new LoggerConfiguration() .MinimumLevel.Debug() .MinimumLevel.Override("Microsoft", Serilog.Events.LogEventLevel.Verbose) .Enrich.FromLogContext() .WriteTo.File(new JsonFormatter(), logFile) .WriteTo.Console() .CreateLogger(); Log.Information($"Logging has started. Logfile can be found at {logFile}"); Logger.LogAction = (o, level, message, parameters) => { if (string.Equals(level, TraceEventType.Error.ToString(), StringComparison.CurrentCultureIgnoreCase)) { Log.Error($"{message}"); } else if (string.Equals(level, TraceEventType.Warning.ToString(), StringComparison.CurrentCultureIgnoreCase)) { Log.Warning($"{message}"); } else if (string.Equals(level, TraceEventType.Information.ToString(), StringComparison.CurrentCultureIgnoreCase)) { Log.Information($"{message}"); } else if (string.Equals(level, TraceEventType.Verbose.ToString(), StringComparison.CurrentCultureIgnoreCase)) { Log.Verbose($"{message}"); } else { Log.Information($"{level} (unknown log level): {message}"); } }; }
static void Main(string[] args) { var config = new ConfigurationBuilder() .AddJsonFile(x => { x.Path = "appsettings.json"; x.FileProvider = new EmbeddedFileProvider(typeof(Program).Assembly); }) .AddJsonFile("appsettings.json", true) .Build(); Log.Logger = new LoggerConfiguration() .WriteTo.Console() .ReadFrom.Configuration(config) .CreateLogger(); LogProvider.SetCurrentLogProvider(new SerilogProvider()); using (var httpServer = new HttpServer(new HttpRequestProvider())) { var endpoint = new IPEndPoint( IPAddress.Parse(config.GetValue <string>("listenAddress")), config.GetValue <int>("port") ); Log.Information("Listening on {endpoint}", endpoint); httpServer.Use(new TcpListenerAdapter(new TcpListener(endpoint))); // TODO: SSL support httpServer.Use(new Controller(config)); httpServer.Use(new ErrorHandler()); httpServer.Start(); if (!args.Contains("--test")) { WaitForExit(); } Log.Information("Exiting gracefully"); } }
private void StartLoadingTransitDbs() { OtherModeBuilder otherModeBuilder; string routableTileCache = null; if (Configuration["RoutableTilesCache"] != null) { routableTileCache = Configuration.GetValue <string>("RoutableTilesCache"); } try { otherModeBuilder = new OtherModeBuilder(routableTileCache, Configuration.GetSection("OsmProfiles")); } catch (Exception e) { Log.Error("Could not create all the other profiles: " + e); otherModeBuilder = new OtherModeBuilder(); } var fileLogger = new FileLogger("logs"); var operators = Configuration.LoadOperators(); var state = new State( operators, otherModeBuilder, otherModeBuilder.RouterDb, fileLogger ) { FreeMessage = "Loading transitdbs" }; Log.Information("Loaded configuration"); State.GlobalState = state; Log.Information("Loaded tdbs are " + string.Join(", ", state.Operators.GetFullView().Operators .Select(kvp => kvp.Name))); state.NameIndex = new NameIndexBuilder(new List <string> { "name:nl", "name", "name:fr" }) .Build(state.Operators.GetFullView().GetStopsReader()); Log.Information("Performing initial runs"); state.FreeMessage = "Running initial data syncs"; var allOperators = state.Operators.GetFullView(); foreach (var provider in allOperators.Operators) { try { Log.Information($"Starting initial run of {provider.Name}"); provider.Synchronizer.InitialRun(); } catch (Exception e) { Log.Error($"Caught exception while running initial data sync: {e.Message}\n{e}"); } } foreach (var provider in allOperators.Operators) { try { Log.Information($"Starting synchronizer for {provider.Name}"); provider.Synchronizer.Start(); } catch (Exception e) { Log.Error($"Caught exception while running initial data sync: {e.Message}\n{e}"); } } state.FreeMessage = "Fully operational"; }
public Task Handle(IHttpContext context, Func <Task> next) { Log.Information("Not found: {0}", context.Request.Uri); context.Response = new HttpResponse(HttpResponseCode.NotFound, "", true); return(Task.CompletedTask); }
static void Main(string[] args) { Log.Logger = new LoggerConfiguration() .MinimumLevel.Debug() .MinimumLevel.Override("Microsoft", LogEventLevel.Information) .Enrich.FromLogContext() .WriteTo.Console() .CreateLogger(); #if DEBUG var loggingBlacklist = new HashSet <string>(); #else var loggingBlacklist = new HashSet <string>(); #endif Logging.Logger.LogAction = (o, level, message, parameters) => { if (loggingBlacklist.Contains(o)) { return; } if (!string.IsNullOrEmpty(o)) { message = $"[{o}] {message}"; } if (level == Logging.TraceEventType.Verbose.ToString().ToLower()) { Log.Debug(message); } else if (level == Logging.TraceEventType.Information.ToString().ToLower()) { Log.Information(message); } else if (level == Logging.TraceEventType.Warning.ToString().ToLower()) { Log.Warning(message); } else if (level == Logging.TraceEventType.Critical.ToString().ToLower()) { Log.Fatal(message); } else if (level == Logging.TraceEventType.Error.ToString().ToLower()) { Log.Error(message); } else { Log.Debug(message); } }; // load data. var routerDb = BuildRouterDb.BuildOrLoad(); // load transit db. var transitDb = BuildTransitDb.BuildOrLoad(); var router = new Router(routerDb) { VerifyAllStoppable = true, CustomRouteBuilder = new Temp.Temp() }; var antwerpen1 = new Coordinate(51.21880619138497f, 4.397792816162109f); var antwerpen2 = new Coordinate(51.21888683113129f, 4.432253837585449f); var brusselHermanTeir = new Coordinate(50.865696744357294f, 4.3497008085250854f); var brusselCentraal = new Coordinate(50.83144119255431f, 4.339964389801025f); var lille = new Coordinate(51.25979327802935f, 4.875869750976562f); var turnhout = new Coordinate(51.3202332109125f, 4.9339234828948975f); var tourEnTaxis = new Coordinate(50.86439661723841f, 4.348719120025635f); var marcheEnFamenne = new Coordinate(50.23142236000259f, 5.333776473999023f); var ieper = new Coordinate(50.85532180383167f, 2.860565185546875f); // // var route = router.Calculate(router.Db.GetSupportedProfile("pedestrian.shortcut"), // antwerpen1, antwerpen2); // File.WriteAllText("route-antwerpen.json", route.ToGeoJson()); // // route = router.Calculate(router.Db.GetSupportedProfile("pedestrian.shortcut"), // brusselHermanTeir, brusselCentraal); // File.WriteAllText("route-brussel.json", route.ToGeoJson()); // var sourceLocation = antwerpen2; var targetLocation = brusselHermanTeir; var routeResult = router.TryCalculateIntermodal(transitDb, router.Db.GetSupportedProfile("pedestrian"), sourceLocation, targetLocation); File.WriteAllText("intermodal-route1.json", routeResult.Value.ToGeoJson()); routeResult = router.TryCalculateIntermodal(transitDb, router.Db.GetSupportedProfile("pedestrian"), antwerpen2, lille); File.WriteAllText("intermodal-route2.json", routeResult.Value.ToGeoJson()); routeResult = router.TryCalculateIntermodal(transitDb, router.Db.GetSupportedProfile("pedestrian"), turnhout, lille); File.WriteAllText("intermodal-route3.json", routeResult.Value.ToGeoJson()); routeResult = router.TryCalculateIntermodal(transitDb, router.Db.GetSupportedProfile("pedestrian"), turnhout, marcheEnFamenne); File.WriteAllText("intermodal-route4.json", routeResult.Value.ToGeoJson()); routeResult = router.TryCalculateIntermodal(transitDb, router.Db.GetSupportedProfile("pedestrian"), turnhout, ieper); File.WriteAllText("intermodal-route5.json", routeResult.Value.ToGeoJson()); }
public void FromAdmin(Message message, SessionID sessionID) { Log.Information("Got {message}", message.ToString()); }
public void ToApp(Message message, SessionID sessionId) { Log.Information("Sending {message}", message.ToString()); }
public void OnLogon(SessionID sessionID) { Log.Information("Logging on session {sessionID}", sessionID); }
public void OnCreate(SessionID sessionID) { Log.Information("Creating session {sessionID}", sessionID); }
public void FromApp(Message message, SessionID sessionID) { Log.Information("Got {message}", message.ToString()); SendFixMessages(sessionID); }