public void logAndAlert(string s, Exception e) { var message = LogC.errMessage(s, e); LogC.err(message); alertUser(s + ": examine " + LogC.errFile() + "\n" + message); }
public static void Main(string[] args) { Directory.CreateDirectory(@"E:\logs"); LogC.setOut("STOServer", @"E:\logs\STOServer." + processId() + ".log", true); LogC.setErr(@"E:\logs\STOServer." + processId() + ".error.log"); AppDomain.CurrentDomain.UnhandledException += handleUncaughtExceptions; S3Cache.setDefaultSqsDbMode(true); if (!(hostname().StartsWith("NY") || hostname().StartsWith("LN"))) { QHttpClient.turnOffProxy(); } var runner = EC2Runner.fromUserData(); S3Cache.setS3Cache(runner.s3Cache()); var lastRunTime = 120; while (trueDat()) { info("lastRunTime: " + lastRunTime); STORequest request = null; try { lastRunTime = processNextMessage(runner, lastRunTime, out request); } catch (Exception e) { LogC.err("failed " + request, e); LogC.info("failed " + request, e); continue; } info("finished " + request); } }
public static Simulator run(int systemId, IEnumerable <Symbol> symbols, IEnumerable <QPortfolio> portfolios, int runNumber, BarLoader data, bool dumpParamsOnly, bool shutdown) { var parameters = new Parameters { { "systemId", systemId }, { "RunMode", (double)RunMode.STO }, { "RunNumber", runNumber } }; try { parameters.runNumber(); LogC.err("" + parameters); if (dumpParamsOnly) { return(null); } var simulator = new Simulator(new SystemArguments(symbols, portfolios, parameters), data, "QUEDGE"); simulator.processBars(); if (shutdown) { simulator.shutdown(); } else { var metrics = simulator.metrics(); LogC.verbose(() => "skipping shutdown based on noShutdown parameter."); LogC.verbose(() => toShortString(metrics["ALL"])); } return(simulator); } catch (Exception e) { throw Bomb.toss("\nFailed in run " + runNumber + "\nUsing:\n" + parameters + "\n", e); } }
void addRow(LiveSystem system) { var row = table.NewRow(); systems.Add(row, system); insertUnknownRow(row, system); plans[system] = new List <Plan>(); setHeartbeatStatus(row, system, SystemStatus.UNKNOWN); setTickStatus(row, system, SystemStatus.UNKNOWN); tickTimers[system] = statusFades(status => setTickStatus(row, system, status)); heartbeatTimers[system] = statusFades(status => setHeartbeatStatus(row, system, status)); lastTickProcessed[system] = DateTime.MinValue; subscribeSystemHeartbeat(row, system); var symbols = convert(list <JMarket>(system.markets()), m => new Symbol(m)); each(symbols, symbol => { try { symbol.subscribe(bar => onTickPublished(row, system, bar.time)); } catch (Exception ex) { LogC.err("exception caught subscribing to tick data for " + symbol + ", " + system, ex); gui.alertUser("exception caught susbcribing to data for " + symbol + ", " + system + ".\nSkipping... see log for details."); } }); }
public void logAndAlert(string s, Exception e) { var message = LogC.errMessage("failed during simulation run\n", e); LogC.err(message); alertUser("failed during simulation. examine " + LogC.errFile() + "\n" + message); }
static object loggedError(string message, Exception e) { LogC.setErr(@"c:\QExcel.log"); LogC.err(message, e); message += ". check " + LogC.errFile() + " to see stack trace."; LogC.setErr(null); return(message); }
void safeProcessUpdate(ObservationListener listener, Date date, double value) { try { listener.onUpdate(date, value); } catch (Exception e) { LogC.err(symbol.name + " failed processing observation " + ymdHuman(date) + ": " + value, e); } }
void safeProcessTick(TickListener listener, JTick t) { try { listener.onTick(t); } catch (Exception e) { LogC.err(symbol.name + " failed processing " + t, e); } }
public static void handleUncaughtException(Exception ex, string appName) { LogC.useJavaLog = false; LogC.setErr(@"C:\logs\" + appName + "Crash.log"); LogC.err("uncaught exception: ", ex); MessageBox.Show( LogC.errMessage("exception written to C:\\logs\\" + appName + "Crash.log: ", ex), "Exception - Crashing", MessageBoxButton.OK, MessageBoxImage.Error); }
public void onMessage(Fields fields) { try { onFields(fields); } catch (Exception e) { LogC.err("exception caught processing message: " + fields, e); throw; } }
T nullIfFails <T>(Producer <T> t, Producer <string> makeMessage) where T : class { try { return(t()); } catch (Exception e) { var message = LogC.errMessage(makeMessage(), e); gui.alertUser(message); LogC.err(message); return(null); } }
/// <summary> /// Called by the system to update the control on-screen /// </summary> /// <param name="e"> /// A PaintEventArgs object containing the Graphics specifications /// for this Paint event. /// </param> protected override void OnPaint(PaintEventArgs e) { lock (this) { if (BeenDisposed || _masterPane == null || GraphPane == null) { return; } if (hScrollBar1 != null && GraphPane != null && vScrollBar1 != null && _yScrollRangeList != null) { SetScroll(hScrollBar1, GraphPane.XAxis, _xScrollRange.Min, _xScrollRange.Max); SetScroll( vScrollBar1, GraphPane.YAxis, _yScrollRangeList[0].Min, _yScrollRangeList[0].Max); } base.OnPaint(e); // Add a try/catch pair since the users of the control can't catch this one try { _masterPane.Draw(e.Graphics); } catch (Exception ex) { LogC.err("failed during draw with ", ex); } } /* * // first, see if an old thread is still running * if ( t != null && t.IsAlive ) * { * t.Abort(); * } * * //dt = new DrawingThread( e.Graphics, _masterPane ); * //g = e.Graphics; * * // Fire off the new thread * t = new Thread( new ParameterizedThreadStart( DoDrawingThread ) ); * //ct.ApartmentState = ApartmentState.STA; * //ct.SetApartmentState( ApartmentState.STA ); * DrawingThreadData dtd; * dtd._g = e.Graphics; * dtd._masterPane = _masterPane; * * t.Start( dtd ); * //ct.Join(); */ }
static void startProcesses(Fields fields) { var nProcs = fields.integer("numProcs"); var mainDir = fields.text("mainDir"); var command = fields.text("command"); Environment.SetEnvironmentVariable("MAIN", mainDir); O.zeroTo(nProcs, i => { LogC.info("starting " + mainDir + " " + command + " -serverIndex " + i); try { var exe = new QFile(mainDir + @"\dotNET\QRun\bin\Release\QRun.exe"); Bomb.unless(exe.exists(), () => "no exe found at " + exe.path()); var process = Process.Start(exe.path(), command + " -serverIndex " + i); processes.get(mainDir + command).Add(process); } catch (Exception e) { LogC.err("failure to launch!", e); throw Bomb.toss("failure to launch!", e); } }); }
void metrics(int runNumber, Action <MetricResults> onResults, bool doRetry) { var request = new Fields(); request.put("RunNumber", runNumber); queue.response(request, response => { try { onResults((MetricResults)deserialize(Strings.fromBase64(response.text("Metrics")))); } catch (Exception e) { LogC.err("exception processing results for run " + runNumber + ", resubmitting...", e); if (doRetry) { metrics(runNumber, onResults, false); } else { throw Bomb.toss("retry failed, bailing out...", e); } } }); }
public List <QNode> nodes() { var bySystem = new LazyDictionary <string, List <LiveSystem> > (system => new List <LiveSystem>()); each(systems, liveSystem => bySystem.get(liveSystem.siv().system()).Add(liveSystem)); var result = list(convert(bySystem.keys(), system => { var liveSystems = bySystem.get(system); var systemNode = new QNode(system, liveSystems.Count, 0); each(liveSystems, liveSystem => { var liveSystemNode = systemNode.add(new LiveSystemNode(liveSystem, 1, 0)); var liveMarkets = list <MsivPv>(liveSystem.liveMarkets()); each(liveMarkets, liveMarket => { try { var symbol = new Symbol(liveMarket.market()); var liveMarketNode = new LiveMarketNode(symbol, 1, 0); liveSystemNode.add(liveMarketNode); var topic = new Topic(liveSystem.topicName(OrderTable.prefix, symbol.name + "." + SystemHeartbeat.SUFFIX)); topic.subscribeIfNeeded(); updateModelNodes += () => updateNode(topic, liveMarket, liveMarketNode); symbol.subscribe(bar => recordMarketDataTickReceived(liveMarket, bar.time)); topic.subscribe(fields => { var tickTime = fields.time("lastTickProcessed"); ticks.get(liveMarket).systemProcessed(date(tickTime)); }); } catch (Exception ex) { LogC.err("exception caught subscribing to tick data for " + liveMarket + ", " + system, ex); gui.alertUser("exception caught susbcribing to data for " + liveMarket + ", " + system + ".\nSkipping... see log for details."); } }); updateModelNodes += () => updateNode(liveSystem, liveSystemNode); }); updateModelNodes += () => updateNode(systemNode); return(systemNode); })); timerManager().everyMillis(1000, updateModelNodes, out timer); LiveLauncher.subscribeHeartbeat(gui.launcherAvailable); LogC.ignore(timer); return(result); }
public static int Main(string[] args) { var q = qAssembly(); var className = args[0]; var type = q.GetType(className, true, false); if (type.IsSubclassOf(typeof(ServiceBase))) { try { var variables = Environment.GetEnvironmentVariables(); var buf = new StringBuilder(); foreach (string name in variables.Keys) { buf.AppendLine("ENV: " + name + "=" + variables[name]); } LogC.eventInfo(buf.ToString(), "QRun"); ServiceBase.Run((ServiceBase)type.GetConstructor(Type.EmptyTypes).Invoke(new object[0])); } catch (Exception e) { LogC.eventError("exception thrown from QRun Service: " + className + "\n", e, "QRun"); return(-1); } } else { try { var main = type.GetMethod("Main", new[] { typeof(string[]) }); var newArgs = new string[args.Length - 1]; zeroTo(args.Length - 1, i => newArgs[i] = args[i + 1]); Bomb.ifNull(main, () => "Could not find Main method in " + className); main.Invoke(null, new[] { newArgs }); } catch (Exception e) { LogC.eventError("exception invoking " + className + ".Main\n", e, "QRun"); LogC.err("exception invoking " + className + ".Main\n", e); return(-1); } } return(0); }
public void err(string message) { LogC.setErr(@"c:\QExcel.log"); LogC.err(message); LogC.setErr(null); }