public void SaveConfigState() { if (!ShiftConfigFiles()) { _logger.LogError("Unable to manage configuration files, quitting!"); _environment.Exit(10); } try { var configJson = _jsonHelper.SerializeObject(_dnsEntriesConfig, true); _file.WriteAllText(CoreConfig.ConfigFile, configJson); _logger.LogDebug("Updated configuration file"); } catch (Exception ex) { _logger.LogUnexpectedException(ex); _environment.Exit(11); } }
public async ValueTask <object> Handle(object message, CancellationToken token = default) { var result = await HandleInternal(message, token); return(result.Success ? result.Message : result.Error); async Task <MessageResult> HandleInternal(object message, CancellationToken token) { _logger.LogDebug("Incoming message {messageName}", message.GetType().Name); switch (message) { case OpenNewTabRequest request: return(await OpenNewTabHandler(request)); case ResizeTabRequest request: ResizeTabHandler(request); return(MessageResult.Empty); case SendInputRequest request: await SendInputRequestHandler(request, token); return(MessageResult.Empty); case OpenOutputRequest request: var stream = ConsumeOutput(request, token); return(new MessageResult { Success = true, Message = stream, }); default: _logger.LogWarning("UnknownMessage {messageName}", message.GetType().Name); return(new MessageResult { Success = false, Error = new UnknownMessageEvent(message.GetType().Name) }); } } }
public void SpawnSucrose() { var top = FindTopInternode(out int leafCount); var bottomInternode = top; var topInternode = top; var bottomCells = bottomInternode.Cells.ToList(); var topCells = topInternode.Cells.ToList(); int amount = topCells.Count; for (int i = 0; i < amount; i++) { logger.LogDebug("Add sucrose from @{From} to @{To}", bottomCells[i].Geometry.BottomCenter, topCells[i].Geometry.BottomCenter); sucroseCarrierCollection.Add(bottomCells[i], topCells[i], bottomCells, 100); } }
public string Get() { _log.LogDebug("Test with Serilog {Structure} logging", "Structured"); _log.LogDebug("Test with Serilog {Structure} logging", "Structured2"); return("Hello world!"); }
public Task StartAsync(CancellationToken cancellationToken) { logger.LogDebug("Starting Plant Simulator"); Stopping = CancellationTokenSource.CreateLinkedTokenSource(cancellationToken); return(Task.Factory.StartNew(Action, cancellationToken, TaskCreationOptions.LongRunning)); }