public static void Log(string msg) { #if UNITY_EDITOR if (!EditorSetting.debug) { return; } #endif msg = "【TheMatrix Debug】" + msg; Debug.Log(msg); OnLog?.Invoke(msg); }
public static void Log(string message) { #if UNITY_EDITOR if (!TheMatrix.EditorSetting.debug) { return; } #endif message = "【" + TypeName + "】" + message; Debug.Log(message); OnLog?.Invoke(message); }
internal static void Warning( string message, string callerClassFullName = "", [CallerFilePath] string callerFilePath = "", [CallerMemberName] string callerMemberName = "", [CallerLineNumber] int callerLineNumber = 0) { lock (SyncLock) { OnLog?.Invoke(new LogEventArgs(LogLevel.Warning, message, callerClassFullName, callerFilePath, callerMemberName, callerLineNumber)); } }
private Task InvalidIdFormatLog(string exceptionMessage) { var logArgs = new LogMessageEventArgs { LogType = MqLogType.InvalidIdFormat, Reason = exceptionMessage }; OnLog?.Invoke(null, logArgs); return(Task.CompletedTask); }
/* * vw_advance_frame_callback -- * * Notification from GGPO we should step foward exactly 1 frame * during a rollback. */ static bool Vw_advance_frame_callback(int flags) { OnLog?.Invoke($"vw_begin_game_callback {flags}"); // Make sure we fetch new inputs from GGPO and use those to update the game state // instead of reading from the keyboard. ulong[] inputs = new ulong[MAX_SHIPS]; ReportFailure(GGPO.SynchronizeInput(ggpo, inputs, MAX_SHIPS, out var disconnect_flags)); AdvanceFrame(inputs, disconnect_flags); return(true); }
public int ReceivePacket() { try { int ret; buffer = new byte[1024]; while (true) { socket.ReceiveTimeout = 3000; try { ret = socket.Receive(buffer, 1024, SocketFlags.None); } catch (SocketException e) { if (e.ErrorCode == 10060) { ret = -1; OnLog.Invoke("recv", "failed to connect to remote host", false); } else { throw e; } } if (ret < 0) { OnLog.Invoke("recv", "recv() failed", false); return(-2); } if (buffer[0] == 0x4D) { if (buffer[1] == 0x15) { OnLog.Invoke("login", "! Others logined.", false); InnerSource = "账户在其他地方登录。"; return(-5); } continue; } break; } return(ret); } catch (ObjectDisposedException) { InnerSource = "Socket被异常关闭。"; return(-5); } }
private Task MessageNotInflightLog(string exceptionMessage) { var logArgs = new LogMessageEventArgs { LogType = MqLogType.MessageNotInflight, Reason = exceptionMessage }; OnLog?.Invoke(null, logArgs); return(Task.CompletedTask); }
private void ConsumerClient_OnConsumeError(object sender, Message e) { var message = e.Deserialize <Null, string>(null, StringDeserializer); var logArgs = new LogMessageEventArgs { LogType = KafkaLogType.ConsumeError, Reason = $@"An error occurred during consume the message; Topic:'{e.Topic}', Message:'{message.Value}', Reason:'{e.Error}'." }; OnLog?.Invoke(sender, logArgs); }
public void Log(string message) { try { Console.WriteLine(message); OnLog?.Invoke(message); } catch (Exception ex) { Log(ex.Message); } }
/// <summary> /// 发送读码命令 /// </summary> public void TriggerOn(int index) { string Command = Config.Trigger[index].Command; if (string.IsNullOrEmpty(Command)) { return; } visionClient.SendAsync(Command); OnLog?.Invoke($"SEND:{Command}"); LogRead.Log.Info($"发送读码命令:{Command}"); }
public async Task Log(WorkflowLogLevel level, string message) { try { await OnLog?.Invoke(level, message); } catch (Exception ex) { OnLog = null; Context.Log(WorkflowLogLevel.Warning, "Realtime processing has failed:\n" + ex.Message + "\nLog streaming has been disabled."); } }
private void LogCallback(IntPtr rk, int level, string fac, string buf) { var name = Util.Marshal.PtrToStringUTF8(LibRdKafka.name(rk)); if (OnLog == null) { // Log to stderr by default if no logger is specified. Loggers.ConsoleLogger(this, new LogMessage(name, level, fac, buf)); return; } OnLog.Invoke(this, new LogMessage(name, level, fac, buf)); }
public static void Message(string str, [CallerMemberName] string member = null, [CallerFilePath] string sourceFilePat = null, [CallerLineNumber] int sourceLineNumber = 0) { if (OnLog != null) { lock (OnLog) { OnLog.Invoke(Level.Message, $"{str}\n", member, sourceFilePat, sourceLineNumber); } } }
private void LogCaller(LoggerEventArgs args) { string eMessage = String.Empty; if (args.Exception != null) { eMessage = args.Exception.Message; } AddLog(new Log(args.LogType, args.Message, (Exception)args.Exception)); OnLog?.Invoke(this, args); }
internal static void Error( string message, Exception?exception = null, string callerClassFullName = "", [CallerFilePath] string callerFilePath = "", [CallerMemberName] string callerMemberName = "", [CallerLineNumber] int callerLineNumber = 0) { lock (SyncLock) { OnLog?.Invoke(new LogEventArgs(LogLevel.Error, message, callerClassFullName, callerFilePath, callerMemberName, callerLineNumber, exception)); } }
protected void WriteStackTraceToLog(Exception exception, IEnumerable <StackFrame> callStack) { OnLog?.Invoke($"Unhandled exception. {exception.GetType().FullName}: {exception.Message}"); var first = true; foreach (var sf in callStack) { var msg = (first ? " ---> " : " at ") + sf.ToStringWithBestSourceLocation(); OnLog?.Invoke(msg); first = false; } OnLog?.Invoke(""); }
public Consumer( IEnumerable <KeyValuePair <string, object> > config, IDeserializer <TKey> keyDeserializer, IDeserializer <TValue> valueDeserializer) { KeyDeserializer = keyDeserializer; ValueDeserializer = valueDeserializer; // TODO: allow deserializers to be set in the producer config IEnumerable<KeyValuePair<string, object>>. if (KeyDeserializer == null) { if (typeof(TKey) != typeof(Null)) { throw new ArgumentNullException("Key deserializer must be specified."); } // TKey == Null -> cast is always valid. KeyDeserializer = (IDeserializer <TKey>) new NullDeserializer(); } if (ValueDeserializer == null) { if (typeof(TValue) != typeof(Null)) { throw new ArgumentNullException("Value deserializer must be specified."); } // TValue == Null -> cast is always valid. ValueDeserializer = (IDeserializer <TValue>) new NullDeserializer(); } consumer = new Consumer(config); consumer.OnLog += (sender, e) => OnLog?.Invoke(sender, e); consumer.OnError += (sender, e) => OnError?.Invoke(sender, e); consumer.OnStatistics += (sender, e) => OnStatistics?.Invoke(sender, e); consumer.OnPartitionsAssigned += (sender, e) => OnPartitionsAssigned?.Invoke(sender, e); consumer.OnPartitionsRevoked += (sender, e) => OnPartitionsRevoked?.Invoke(sender, e); consumer.OnOffsetCommit += (sender, e) => OnOffsetCommit?.Invoke(sender, e); // TODO: bypass this.consumer for this event to optimize perf. consumer.OnMessage += (sender, e) => OnMessage?.Invoke(sender, new Message <TKey, TValue> ( e.Topic, e.Partition, e.Offset, KeyDeserializer.Deserialize(e.Key), ValueDeserializer.Deserialize(e.Value), e.Timestamp, e.Error ) ); consumer.OnPartitionEOF += (sender, e) => OnPartitionEOF?.Invoke(sender, e); }
/* * vw_save_game_state_callback -- * * Save the current state to a buffer and return it to GGPO via the * buffer and len parameters. */ static unsafe bool Vw_save_game_state_callback(void **buffer, int *length, int *checksum, int frame) { OnLog?.Invoke($"vw_save_game_state_callback {frame}"); Debug.Assert(gs != null); var bytes = GameState.ToBytes(gs); * checksum = Helper.CalcFletcher32(bytes); * length = bytes.Length; var ptr = Helper.ToPtr(bytes); *buffer = ptr; cache[(long)ptr] = bytes; return(true); }
public void Log(LogEntry entry) { if (Level < entry.Level) { return; } Task.Run(delegate { OnLog?.Invoke(this, entry); }); Console.WriteLine($"[{entry.Level}][{entry.DateTime}] {entry.Message}"); }
/// <summary> /// Default constructor /// </summary> /// <param name="configuration">The test-bed adapter configuration information</param> internal AbstractProducer(Configuration configuration) { _configuration = configuration; _producer = new ProducerBuilder <EDXLDistribution, T>(_configuration.ProducerConfig) .SetKeySerializer(new AvroSerializer <EDXLDistribution>(configuration.SchemaRegistryClient)) .SetValueSerializer(new AvroSerializer <T>(configuration.SchemaRegistryClient)) // Raised on critical errors, e.g. connection failures or all brokers down. .SetErrorHandler((sender, error) => OnError?.Invoke(sender, error)) // Raised when there is information that should be logged. .SetLogHandler((sender, log) => OnLog?.Invoke(sender, log)) .Build(); _messageQueue = new Queue <KeyValuePair <T, string> >(); }
private void Log(string message) { if (string.IsNullOrEmpty(message)) { return; } OnLog?.Invoke(this, new LogEventArgs(message)); if (IsWriteLogToFile) { _dataLogger.Log(message); } }
/// <summary> /// 委托回报 /// </summary> /// <typeparam name="T1"></typeparam> /// <typeparam name="T2"></typeparam> /// <param name="pInputOrder">委托信息</param> /// <param name="pRspInfo">错误信息</param> /// <param name="nRequestID"></param> /// <param name="bIsLast"></param> public void OnRspOrderInsert_ <T1, T2>(T1 pInputOrder, T2 pRspInfo, int nRequestID, bool bIsLast) { object obj = pRspInfo; var error = (ErrorInfo)obj; if (error.ErrorID == 0) { OnLog?.Invoke($"委托成功回报:{error.ErrorMsg}"); } else { OnLog?.Invoke($"委托失败回报:{error.ErrorMsg}"); } }
/// <summary> /// 查询投资者响应 /// </summary> /// <typeparam name="T1"></typeparam> /// <typeparam name="T2"></typeparam> /// <param name="pInvestor"></param> /// <param name="pRspInfo"></param> /// <param name="nRequestID"></param> /// <param name="bIsLast"></param> public void OnRspQryInvestor_ <T1, T2>(T1 pInvestor, T2 pRspInfo, int nRequestID, bool bIsLast) { object obj = pRspInfo; var error = (ErrorInfo)obj; if (error.ErrorID == 0) { OnLog?.Invoke($"查询投资者成功:{error.ErrorMsg}"); } else { OnLog?.Invoke($"查询投资者失败:{error.ErrorMsg}"); } }
/// <summary> /// 行情账号登出回报 /// </summary> /// <typeparam name="T1"></typeparam> /// <typeparam name="T2"></typeparam> /// <param name="onUserLogOut"></param> /// <param name="error"></param> /// <param name="n"></param> /// <param name="b"></param> public void OnRspUserLogout_ <T1, T2>(T1 onUserLogOut, T2 error, int n, bool b) { object obj = error; ErrorInfo error_d = (ErrorInfo)obj; if (error_d.ErrorID == 0) { OnLog?.Invoke($"CTP行情账号登出成功"); } else { OnLog?.Invoke($"CTP行情账号登出失败,错误信息:{error_d.ErrorMsg}"); } }
private static void WriteToLog(string message, LogLevel level) { LogColor color = _theme?.GetColor(level) ?? new LogColor(); Console.ForegroundColor = color.Foreground ?? ConsoleColor.White; Console.BackgroundColor = color.Background ?? ConsoleColor.Black; OnLog?.Invoke($"{_createHeader(level)} {message}", level); Console.ResetColor(); }
public void Connect(string serverAddress = "10.0.1.1:13000") { ServerAddress = serverAddress; string result = string.Empty; // Create DnsEndPoint. The hostName and port are passed in to this method. string[] address = ServerAddress.Split(':'); int port = 13000; DnsEndPoint hostEntry = new DnsEndPoint(address[0], address.Length == 2 ? int.Parse(address[1], System.Globalization.NumberFormatInfo.InvariantInfo) : port); // cleanup any previous connection if (_socket != null && _socket.Connected) { _socket.Dispose(); OnConnect?.Invoke(this, new ConnectedEventArgs(false)); } // Create a stream-based, TCP socket using the InterNetwork Address Family. _socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); // Create a SocketAsyncEventArgs object to be used in the connection request SocketAsyncEventArgs socketEventArg = new SocketAsyncEventArgs(); socketEventArg.RemoteEndPoint = hostEntry; // Inline event handler for the Completed event. // Note: This event handler was implemented inline in order to make this method self-contained. socketEventArg.Completed += new EventHandler <SocketAsyncEventArgs>(delegate(object s, SocketAsyncEventArgs e) { if (e.SocketError == SocketError.Success) { OnConnect?.Invoke(this, new ConnectedEventArgs(true)); } OnLog?.Invoke(this, new LogEventArgs("Server response: " + e.SocketError.ToString())); // listen SocketAsyncEventArgs traceEventArg = new SocketAsyncEventArgs(); traceEventArg.RemoteEndPoint = hostEntry; ResetBuffer(traceEventArg); traceEventArg.Completed += SocketReceive; _socket.ReceiveAsync(traceEventArg); }); OnLog?.Invoke(this, new LogEventArgs(string.Format("Connecting {0}:{1}", hostEntry.Host, hostEntry.Port))); // Make an asynchronous Connect request over the socket _socket.ConnectAsync(socketEventArg); }
/// <summary> /// Creates a new log entry. /// </summary> /// <param name="message"> /// The message of this log entry. /// </param> /// <param name="level"> /// The log level describes the importance of an log entry. /// If its lower than the logFilter-level, which was set in the constructor, the log entry wont be shown in the console. /// </param> /// <param name="memberName"> /// Filled by the compiler. Ignore this field. /// </param> /// <param name="sourceFilePath"> /// Filled by the compiler. Ignore this field. /// </param> /// <param name="sourceLineNumber"> /// Filled by the compiler. Ignore this field. /// </param> public void Log(string message, LogLevel level = LogLevel.Info, [System.Runtime.CompilerServices.CallerMemberName] string memberName = "", [System.Runtime.CompilerServices.CallerFilePath] string sourceFilePath = "", [System.Runtime.CompilerServices.CallerLineNumber] int sourceLineNumber = 0) { String clazz = Path.GetFileNameWithoutExtension(sourceFilePath); var entry = new LogEntry(message, level, clazz, memberName, sourceLineNumber); OnLog?.Invoke(entry); if (level >= LogFilter) { OnLogFiltered?.Invoke(entry); } }
public void AddCustomResolver(Type type, Func <CustomResolverArgs, object> func) { if (customResolvers.ContainsKey(type)) { OnLog?.Invoke($"[ERROR] There is already a custom resolver for type '{type.FullName}'"); return; } if (func == null) { OnLog?.Invoke($"[ERROR] Null arg {nameof(func)}."); return; } customResolvers.Add(type, func); }
/// <summary> /// Logs a line to this logger. /// </summary> /// <param name="msg">The contents of this log.</param> /// <param name="type">The type of log.</param> public void Log(string msg, DiscoreLogLevel type) { if (type >= MinimumLevel) { if (!string.IsNullOrWhiteSpace(Prefix)) { // Prefix msg = $"[{Prefix}] {msg}"; } try { OnLog?.Invoke(this, new DiscoreLogEventArgs(new DiscoreLogMessage(msg, type, DateTime.Now))); } // Log methods need to be guaranteed to never throw exceptions. catch { } } }
public void OnRspUserLogout_ <T1, T2>(T1 pUserLogout, T2 pRspInfo, int nRequestID, bool bIsLast) { ///登出回报 object obj = pRspInfo; var error = (ErrorInfo)obj; if (error.ErrorID == 0) { OnLog?.Invoke($"CTP交易账户登出成功:{error.ErrorMsg}"); } else { OnLog?.Invoke($"CTP交易账户登出失败:{error.ErrorMsg}"); } }