public void ReceiveCallback(IAsyncResult ar) { LogDelegate log = new LogDelegate(this.Bench.Log); try { UdpClient u = (UdpClient)((UdpState)(ar.AsyncState)).u; IPEndPoint e = (IPEndPoint)((UdpState)(ar.AsyncState)).e; Byte[] receiveBytes = u.EndReceive(ar, ref e); string receiveString = Encoding.ASCII.GetString(receiveBytes); UDPResponse = Encoding.ASCII.GetString(receiveBytes, 0, receiveBytes.Length); string verboseLog = "Received broadcast from " + e.ToString() + ":\n" + UDPResponse + "\n"; log(verboseLog); Console.WriteLine("Received: {0}", receiveString); messageReceived = true; } catch (Exception e) { UDPResponse = ""; log(e.ToString()); } }
public TThreadedServer(TProcessor processor, TServerTransport serverTransport, LogDelegate logDelegate) : this(processor, serverTransport, new TTransportFactory(), new TTransportFactory(), new TBinaryProtocol.Factory(), new TBinaryProtocol.Factory(), DEFAULT_MAX_THREADS, logDelegate) { }
public TThreadPoolServer(TProcessor processor, TServerTransport serverTransport, LogDelegate logDelegate) : this(new TSingletonProcessorFactory(processor), serverTransport, new TTransportFactory(), new TTransportFactory(), new TBinaryProtocol.Factory(), new TBinaryProtocol.Factory(), DEFAULT_MIN_THREADS, DEFAULT_MAX_THREADS, logDelegate) { }
public TThreadPoolServer(Processor processor, ServerTransport serverTransport, LogDelegate logDelegate) : this(processor, serverTransport, new TransportFactory(), new TransportFactory(), new BinaryProtocol.Factory(), new BinaryProtocol.Factory(), DEFAULT_MIN_THREADS, DEFAULT_MAX_THREADS, logDelegate) { }
static ULDebug() { #if UNITY Log = UnityEngine.Debug.Log; LogError = UnityEngine.Debug.LogError; #endif }
public TSimpleServer(TProcessor processor, TServerTransport serverTransport, LogDelegate logDel) : base( processor, serverTransport, new TTransportFactory(), new TTransportFactory(), new TBinaryProtocol.Factory(), new TBinaryProtocol.Factory(), logDel) { }
internal Logger(string name, ILogger logger, ConfigSource config) { this.name = name; this.logger = logger; this.config = config; logDelegate = new LogDelegate(Log); }
public TServer(TProcessor processor, TServerTransport serverTransport, LogDelegate logDelegate) : this( processor, serverTransport, new TTransportFactory(), new TTransportFactory(), new TBinaryProtocol.Factory(), new TBinaryProtocol.Factory(), DefaultLogDelegate) { }
public MultiConverterModel(Part part, Vessel vessel, LogDelegate logDelegate) { this.part = part; this.vessel = vessel; this.logDelegate = logDelegate; this.converters = new List<ModuleResourceConverter>(); }
public FormServers() { // // Required for Windows Form Designer support // InitializeComponent(); logDelegate=new LogDelegate(m_Log); m_Globalize(); }
public void Log( string message ) { if( this.textBox1.InvokeRequired ) { LogDelegate d = new LogDelegate( LogInternal ); this.Invoke ( d, new object[] { message } ); } else { LogInternal( message ); } }
public PacketSniffer(LogDelegate logDelegate) { Log = logDelegate; aborting = false; device = null; packetLock = new object(); packetAvailiable = new AutoResetEvent(false); disposed = false; }
public LoggerSql(SqlConnection connection, LogDelegate logCommand) { if (connection == null) throw new ArgumentNullException("The SQL connection was null when passed into LoggerSql"); if (logCommand == null) throw new ArgumentNullException("No LogDelegate was specified on the constructor to LoggerSql"); this.connection = connection; this.logCommand = logCommand; this.Count = 0; }
public void newCommand(string p) { if (txtCommandsUsed.InvokeRequired) { LogDelegate d = new LogDelegate(newCommand); this.Invoke(d, new object[] { p }); } else { txtCommandsUsed.AppendTextAndScroll(p); } }
public TServerAsync(TProcessorAsync processor, TServerTransportAsync serverTransport, LogDelegate logDelegate) : this(processor, serverTransport, new TTransportFactoryAsync(), new TTransportFactoryAsync(), new TCompactProtocolAsync.Factory(), new TCompactProtocolAsync.Factory(), logDelegate) { }
public Main() { InitializeComponent(); LogDelegateInstance = new LogDelegate(_Log); ErrorDelegateInstance = new ErrorDelegate(_Error); StartServer sserver = new StartServer(_StartServer); Thread serverConnection = new Thread(new ThreadStart(sserver)); serverConnection.Start(); //Thread.Sleep(5000); }
public SilentForm() : base() { InitializeComponent(); Alert = new AlertDelegate(AlertMethod); Exit = new ExitDelegate(ExitMethod); FatalExit = new FatalExitDelegate(FatalExitMethod); Log = new LogDelegate(LogMethod); ReportProgress = new ReportProgressDelegate(ReportProgressMethod); Info = new InfoDelegate(InfoMethod); logfile=File.OpenWrite(Path.GetDirectoryName(Application.ExecutablePath)+"\\cuetoogg.log.txt"); }
public void log(string message) { if (this.InvokeRequired) { LogDelegate d = new LogDelegate(log); this.Invoke(d, new object[] { message }); } else { txtLog.AppendText(Environment.NewLine + message); } }
static CCLog () { #if DEBUG // We wrap this in a DEBUG conditional as there is no sense to attach a lambda to // the logger if it will just be an empty invoke. The Debug.WriteLine will conditionally // be compiled out when building for Release anyway. Logger = (format, args) => { Debug.WriteLine(format, args); }; #endif }
//!!logDelegate cannot block! public static void CreateColumn(String header, LogDelegate logDelegate) { lock (loggingLock) { if (loggingStarted) return; headerList.Add(header); delegateList.Add(logDelegate); } return; }
public void log(string msg) { if (this.InvokeRequired == false) { statusTextBox.Text += msg + Environment.NewLine; } else { LogDelegate logDelegate = new LogDelegate(log); this.BeginInvoke(logDelegate, new object[] { msg }); } logInfo(msg); }
public TThreadedServer(TProcessor processor, TServerTransport serverTransport, TTransportFactory inputTransportFactory, TTransportFactory outputTransportFactory, TProtocolFactory inputProtocolFactory, TProtocolFactory outputProtocolFactory, int maxThreads, LogDelegate logDel) : base(processor, serverTransport, inputTransportFactory, outputTransportFactory, inputProtocolFactory, outputProtocolFactory, logDel) { this.maxThreads = maxThreads; clientQueue = new Queue<TTransport>(); clientLock = new object(); clientThreads = new THashSet<Thread>(); }
public frmDTClient() { InitializeComponent(); this.FormBorderStyle = FormBorderStyle.Fixed3D; Log += WriteToUILog; LogMe = WriteToUILog; filteredSignals = new List<double>(MaxSignals); dgvSignalData.Rows.Add(100); chartSignalData.ChartAreas[0].AxisX.Interval = 100; chartSignalData.ChartAreas[0].AxisX.MajorTickMark.Interval = 100; chartSignalData.ChartAreas[0].AxisX.MinorTickMark.Interval = 50; chartSignalData.ChartAreas[0].CursorX.IsUserSelectionEnabled = true; chartSignalData.Series[0].Points.Clear(); chartSignalData.Series[1].Points.Clear(); }
public TThreadPoolServer(TProcessor processor, TServerTransport serverTransport, TTransportFactory inputTransportFactory, TTransportFactory outputTransportFactory, TProtocolFactory inputProtocolFactory, TProtocolFactory outputProtocolFactory, int minThreadPoolThreads, int maxThreadPoolThreads, LogDelegate logDel) : base(processor, serverTransport, inputTransportFactory, outputTransportFactory, inputProtocolFactory, outputProtocolFactory, logDel) { if (!ThreadPool.SetMaxThreads(maxThreadPoolThreads, maxThreadPoolThreads)) { throw new Exception("Error: could not SetMaxThreads in ThreadPool"); } }
public MKSTemplatesModel(Part part, Vessel vessel, LogDelegate logDelegate, string template = "MKSTEMPLATE") { this.part = part; this.vessel = vessel; this.logDelegate = logDelegate; _templateNodeName = template; this.templateNodes = GameDatabase.Instance.GetConfigNodes(template); if (templateNodes == null) { Log("MKSTemplatesModel templateNodes == null!"); return; } }
private void Log(string message) { if (this.logText.InvokeRequired) { LogDelegate callback = new LogDelegate(Log); this.Invoke(callback, new object[] { message }); return; } if (this.logText.Text.Length == 0) { this.logText.AppendText(message); } else { this.logText.AppendText(Environment.NewLine + message); } }
public void Log(Log log) { try { if (this.InvokeRequired) { var d = new LogDelegate(this.Log); this.Invoke(d, log); } else { if (log?.Message != null) { this.txtLog.AppendText($"{log.LogType} - {log.Message}\n"); } } } catch { } }
public void Log(Log log) { if (log == null) return; try { if (this.InvokeRequired) { var d = new LogDelegate(this.Log); this.Invoke(d, log); } else { if (log.Message != null) { this.txtLog.AppendText(string.Format("{0} - {1}\n", log.LogType, log.Message)); } } } catch { } }
public void AppendTextAndScroll(string text) { bool bottomFlag = false; int VSmin; int VSmax; int sbOffset; int savedVpos; // Make sure this is done in the UI thread if (this.InvokeRequired) { LogDelegate d = new LogDelegate(AppendTextAndScroll); this.Invoke(d, new object[] { text, true }); } else { // Win32 magic to keep the textbox scrolling to the newest append to the textbox unless // the user has moved the scrollbox up sbOffset = (int)((this.ClientSize.Height - SystemInformation.HorizontalScrollBarHeight) / (this.Font.Height)); savedVpos = GetScrollPos(this.Handle, SB_VERT); GetScrollRange(this.Handle, SB_VERT, out VSmin, out VSmax); if (savedVpos >= (VSmax - sbOffset - 1)) bottomFlag = true; this.AppendText(text + Environment.NewLine); if (bottomFlag) { GetScrollRange(this.Handle, SB_VERT, out VSmin, out VSmax); savedVpos = VSmax - sbOffset; bottomFlag = false; } SetScrollPos(this.Handle, SB_VERT, savedVpos, true); PostMessageA(this.Handle, WM_VSCROLL, SB_THUMBPOSITION + 0x10000 * savedVpos, 0); } this.Text = ReturnLast250Lines(this.Text); }
public TSimpleServer(TProcessor processor, TServerTransport serverTransport, LogDelegate logDel) : base(processor, serverTransport, new TTransportFactory(), new TTransportFactory(), new TBinaryProtocol.Factory(), new TBinaryProtocol.Factory(), logDel) { }
public LogEventHandler(LogEventKind kind, LogDelegate onLog) : this() { this._eventKind = kind; this.OnLog += onLog; }
public TThreadPoolServer(TProcessor processor, TServerTransport serverTransport, LogDelegate logDelegate) : this(processor, serverTransport, new TTransportFactory(), new TTransportFactory(), new TCompactProtocol.Factory(), new TCompactProtocol.Factory(), DEFAULT_MIN_THREADS, DEFAULT_MAX_THREADS, logDelegate) { }
public TServer(TProcessor processor, TServerTransport serverTransport, LogDelegate logDelegate) : this(processor, serverTransport, new TTransportFactory(), new TTransportFactory(), new TBinaryProtocol.Factory(), new TBinaryProtocol.Factory(), DefaultLogDelegate) { }
private static bool Initialize() { try { var logEventLevelType = FindType("NLog.LogLevel", "NLog"); if (logEventLevelType == null) { throw new LibLogException("Type NLog.LogLevel was not found."); } var levelFields = logEventLevelType.GetFields().ToList(); s_levelTrace = levelFields.First(x => x.Name == "Trace").GetValue(null); s_levelDebug = levelFields.First(x => x.Name == "Debug").GetValue(null); s_levelInfo = levelFields.First(x => x.Name == "Info").GetValue(null); s_levelWarn = levelFields.First(x => x.Name == "Warn").GetValue(null); s_levelError = levelFields.First(x => x.Name == "Error").GetValue(null); s_levelFatal = levelFields.First(x => x.Name == "Fatal").GetValue(null); var logEventInfoType = FindType("NLog.LogEventInfo", "NLog"); if (logEventInfoType == null) { throw new LibLogException("Type NLog.LogEventInfo was not found."); } var loggingEventConstructor = logEventInfoType.GetConstructorPortable(logEventLevelType, typeof(string), typeof(IFormatProvider), typeof(string), typeof(object[]), typeof(Exception)); var loggerNameParam = Expression.Parameter(typeof(string)); var levelParam = Expression.Parameter(typeof(object)); var messageParam = Expression.Parameter(typeof(string)); var messageArgsParam = Expression.Parameter(typeof(object[])); var exceptionParam = Expression.Parameter(typeof(Exception)); var levelCast = Expression.Convert(levelParam, logEventLevelType); var newLoggingEventExpression = Expression.New(loggingEventConstructor, levelCast, loggerNameParam, Expression.Constant(null, typeof(IFormatProvider)), messageParam, messageArgsParam, exceptionParam ); s_logEventInfoFact = Expression.Lambda <Func <string, object, string, object[], Exception, object> >( newLoggingEventExpression, loggerNameParam, levelParam, messageParam, messageArgsParam, exceptionParam).Compile(); var loggerType = FindType("NLog.Logger", "NLog"); s_loggerNameDelegate = GetLoggerNameDelegate(loggerType); s_logEventDelegate = GetLogEventDelegate(loggerType, logEventInfoType); s_isTraceEnabledDelegate = GetIsEnabledDelegate(loggerType, "IsTraceEnabled"); s_isDebugEnabledDelegate = GetIsEnabledDelegate(loggerType, "IsDebugEnabled"); s_isInfoEnabledDelegate = GetIsEnabledDelegate(loggerType, "IsInfoEnabled"); s_isWarnEnabledDelegate = GetIsEnabledDelegate(loggerType, "IsWarnEnabled"); s_isErrorEnabledDelegate = GetIsEnabledDelegate(loggerType, "IsErrorEnabled"); s_isFatalEnabledDelegate = GetIsEnabledDelegate(loggerType, "IsFatalEnabled"); s_traceDelegate = GetLogDelegate(loggerType, "Trace"); s_debugDelegate = GetLogDelegate(loggerType, "Debug"); s_infoDelegate = GetLogDelegate(loggerType, "Info"); s_warnDelegate = GetLogDelegate(loggerType, "Warn"); s_errorDelegate = GetLogDelegate(loggerType, "Error"); s_fatalDelegate = GetLogDelegate(loggerType, "Fatal"); s_traceExceptionDelegate = GetLogExceptionDelegate(loggerType, "TraceException"); s_debugExceptionDelegate = GetLogExceptionDelegate(loggerType, "DebugException"); s_infoExceptionDelegate = GetLogExceptionDelegate(loggerType, "InfoException"); s_warnExceptionDelegate = GetLogExceptionDelegate(loggerType, "WarnException"); s_errorExceptionDelegate = GetLogExceptionDelegate(loggerType, "ErrorException"); s_fatalExceptionDelegate = GetLogExceptionDelegate(loggerType, "FatalException"); s_structuredLoggingEnabled = IsStructuredLoggingEnabled(); } catch (Exception ex) { s_initializeException = ex; return(false); } return(true); }
public static void RemoveLogDelegate(LogDelegate logDelegate) { logDelegates.Remove(logDelegate); }
public unsafe static extern bool Init(ReportErrorDelegate reportErrorDelegate, out IntPtr errorString, LogDelegate logDelegate, float cookingParamsSkinWidth);
public TThreadPoolServer(TProcessor processor, TServerTransport serverTransport, LogDelegate logDelegate) : this(new TSingletonProcessorFactory(processor), serverTransport, new TTransportFactory(), new TTransportFactory(), new TBinaryProtocol.Factory(), new TBinaryProtocol.Factory(), new Configuration(), logDelegate) { }
public static extern void MagickNET_SetLogDelegate(LogDelegate method);
public TThreadPoolServer(TProcessorFactory processorFactory, TServerTransport serverTransport, TTransportFactory inputTransportFactory, TTransportFactory outputTransportFactory, TProtocolFactory inputProtocolFactory, TProtocolFactory outputProtocolFactory, Int32 minThreadPoolThreads, Int32 maxThreadPoolThreads, LogDelegate logDel) : this(processorFactory, serverTransport, inputTransportFactory, outputTransportFactory, inputProtocolFactory, outputProtocolFactory, new Configuration(minThreadPoolThreads, maxThreadPoolThreads), logDel) { }
public static void Sync(ConfigFile configFile, LogDelegate Log) { ConfigFileSyncPermissionsSection config = configFile.AbsencePermissions; Log("========= ABSENCES ========= "); if (!config.AllowSync) { Log("This sync module is disabled in config file - skipping"); return; } // Parse the school year from the config file, we'll need it later InternalSchoolYearRepository _schoolYearRepo = new InternalSchoolYearRepository(configFile.DatabaseConnectionString_Internal); SchoolYear schoolYear = _schoolYearRepo.Get(configFile.SchoolYearName); if (schoolYear == null) { throw new InvalidSchoolYearException("School year from config file is invalid"); } SLAbsenceRepository externalRepository = new SLAbsenceRepository(configFile.DatabaseConnectionString_SchoolLogic, schoolYear); InternalAbsenceRepository internalRepository = new InternalAbsenceRepository(configFile.DatabaseConnectionString_Internal); List <Absence> externalObjects = externalRepository.GetAll(); List <Absence> internalObjects = internalRepository.GetForSchoolYear(schoolYear.ID); Log("Found " + internalObjects.Count() + " absences in internal database for this school year"); Log("Found " + externalObjects.Count() + " absences in external database"); // Find previously unknown schools // Find schools that need an update List <Absence> previouslyUnknown = new List <Absence>(); List <Absence> needingUpdate = new List <Absence>(); List <Absence> noLongerExistsInExternalSystem = new List <Absence>(); int doneCount = 0; int totalExternalObjects = externalObjects.Count(); decimal donePercent = 0; decimal doneThresholdPercent = (decimal)0.01; decimal doneThresholdIncrease = (decimal)0.01; foreach (Absence externalObject in externalObjects) { // Check to see if we know about this school already Absence internalObject = internalObjects.GetWithID(externalObject.ID); if (internalObject == null) { previouslyUnknown.Add(externalObject); } // Check to see if this school requires an update if (internalObject != null) { UpdateCheck check = internalObject.CheckIfUpdatesAreRequired(externalObject); if ((check == UpdateCheck.UpdatesRequired) || (config.ForceUpdate)) { needingUpdate.Add(externalObject); } } doneCount++; donePercent = (decimal)((decimal)doneCount / (decimal)totalExternalObjects); if (donePercent > doneThresholdPercent) { doneThresholdPercent = doneThresholdPercent + doneThresholdIncrease; Log((int)(donePercent * 100) + "% finished inspecting objects"); } if (doneCount == totalExternalObjects) { Log("100% finished inspecting objects"); } } // Find schools that are no longer in the database that could potentially be cleaned up if (config.AllowRemovals) { List <int> foundIDs = externalRepository.GetAllIDs(); foreach (Absence internalObject in internalObjects) { if (!foundIDs.Contains(internalObject.ID)) { noLongerExistsInExternalSystem.Add(internalObject); } } } Log("Found " + previouslyUnknown.Count() + " previously unknown"); Log("Found " + needingUpdate.Count() + " with updates"); Log("Found " + noLongerExistsInExternalSystem.Count() + " not in external database"); // Commit these changes to the database if (previouslyUnknown.Count > 0) { if (config.AllowAdds) { Log(" > Adding " + previouslyUnknown.Count() + " new objects"); internalRepository.Add(previouslyUnknown); } else { Log(" > Not allowed to add, skipping " + previouslyUnknown.Count() + " adds"); } } if (needingUpdate.Count > 0) { if (config.AllowUpdates) { Log(" > Updating " + needingUpdate.Count() + " objects"); internalRepository.Update(needingUpdate); } else { Log(" > Not allowed to do updates, skipping " + needingUpdate.Count() + " updates"); } } if (noLongerExistsInExternalSystem.Count > 0) { if (config.AllowRemovals) { Log(" > If removals were implemented, we would remove " + noLongerExistsInExternalSystem.Count() + " objects here"); } else { Log(" > Not allowed to remove, skipping " + noLongerExistsInExternalSystem.Count() + " removals"); } } }
/// <summary> /// Initializes a new instance of the <see cref="Ceen.Httpd.Logging.FunctionLogger"/> class. /// </summary> /// <param name="func">The logging function.</param> public FunctionLogger(LogDelegate func) { m_func = func; }
/// <summary> /// Specify a logging delegate /// </summary> public void AddLogDelegate(LogDelegate iLogDelegate, bool iDeepLogging = false) { _logDelegate = iLogDelegate; _deepLogging = iDeepLogging; }
public SoftSwitchStatsTask(string pIPAddress, LogDelegate pLog) { IPAddress.TryParse(pIPAddress, out ipAddress); port = 7000; log = pLog; }
public CommunicationController(LogDelegate logDelegate, IRedisDatabase redisDatabase) { LogDelegate = logDelegate; RedisDatabase = redisDatabase; }
public void addLogListener(LogDelegate logDelegate) { this.logger += logDelegate; }
public static TimeStampToken RequestTimeStamp(string tsaService, string fileName, string hashAlg, string policy, string nonce, bool certReq, UserCredentials credentials, LogDelegate logger, bool logExceptions) { Oid hashOid = null; switch (hashAlg) { case "sha1": hashOid = Oid.SHA1; break; case "sha256": hashOid = Oid.SHA256; break; case "sha512": hashOid = Oid.SHA512; break; case "md5": hashOid = Oid.MD5; break; default: hashOid = Oid.SHA256; break; } return(RequestTimeStamp(tsaService, fileName, hashOid, policy, nonce, certReq, credentials, logger, logExceptions)); }
public static void Sync(ConfigFile configFile, LogDelegate Log) { ConfigFileSyncPermissionsSection config = configFile.StudentPermissions; Log("========= STUDENTS ========= "); if (!config.AllowSync) { Log("This sync module is disabled in config file - skipping"); return; } SLStudentRepository externalRepository = new SLStudentRepository(configFile.DatabaseConnectionString_SchoolLogic); InternalStudentRepository internalRepository = new InternalStudentRepository(configFile.DatabaseConnectionString_Internal); List <Student> externalObjects = externalRepository.GetAll(); List <Student> previouslyUnknown = new List <Student>(); List <Student> needingUpdate = new List <Student>(); List <Student> noLongerExistsInExternalSystem = new List <Student>(); int doneCount = 0; int totalExternalObjects = externalObjects.Count(); decimal donePercent = 0; decimal doneThresholdPercent = (decimal)0.1; decimal doneThresholdIncrease = (decimal)0.1; foreach (Student externalObject in externalObjects) { // Objects we don't have in the database Student internalObject = internalRepository.Get(externalObject.iStudentID); if (internalObject == null) { previouslyUnknown.Add(externalObject); } // Objects requiring update if (internalObject != null) { UpdateCheck check = internalObject.CheckIfUpdatesAreRequired(externalObject); if ((check == UpdateCheck.UpdatesRequired) || (config.ForceUpdate)) { needingUpdate.Add(externalObject); } } doneCount++; donePercent = (decimal)((decimal)doneCount / (decimal)totalExternalObjects); if (donePercent > doneThresholdPercent) { doneThresholdPercent = doneThresholdPercent + doneThresholdIncrease; Log((int)(donePercent * 100) + "% finished inspecting objects"); } if (doneCount == totalExternalObjects) { Log("100% finished inspecting objects"); } } // Objects in the internal database that aren't in the external database if (config.AllowRemovals) { List <int> foundIDs = externalRepository.GetAllIDs(); foreach (Student internalObject in internalRepository.GetAll()) { if (!foundIDs.Contains(internalObject.iStudentID)) { noLongerExistsInExternalSystem.Add(internalObject); } } } Log("Found " + internalRepository.GetAll().Count() + " students in internal database"); Log("Found " + externalObjects.Count() + " students in external database"); Log("Found " + previouslyUnknown.Count() + " previously unknown"); Log("Found " + needingUpdate.Count() + " with updates"); Log("Found " + noLongerExistsInExternalSystem.Count() + " not in external database"); // Commit these changes to the database if (previouslyUnknown.Count > 0) { if (config.AllowAdds) { Log(" > Adding " + previouslyUnknown.Count() + " new objects"); internalRepository.Add(previouslyUnknown); } else { Log(" > Not allowed to add, skipping " + previouslyUnknown.Count() + " adds"); } } if (needingUpdate.Count > 0) { if (config.AllowUpdates) { Log(" > Updating " + needingUpdate.Count() + " objects"); internalRepository.Update(needingUpdate); } else { Log(" > Not allowed to do updates, skipping " + needingUpdate.Count() + " updates"); } } if (noLongerExistsInExternalSystem.Count > 0) { if (config.AllowRemovals) { Log(" > If removals were implemented, we would remove " + noLongerExistsInExternalSystem.Count() + " objects here"); } else { Log(" > Not allowed to remove, skipping " + noLongerExistsInExternalSystem.Count() + " removals"); } } }
public Logger(LogDelegate method) { _method = method; }
/// <summary> /// 外部依赖初始化 /// </summary> /// <param name="luaFileLoader"></param> /// <param name="logDelegate"></param> /// <param name="logWarn"></param> /// <param name="logError"></param> public static void ExternalDependenceInit(CustomFileLoader luaFileLoader, LogDelegate logDelegate, LogDelegate logWarn, LogDelegate logError) { Debug.m_Log = logDelegate; Debug.m_LogWarn = logWarn; Debug.m_LogError = logError; //Core.Debug.Assert = Debug.Assert; Core.LuaMgr.AddFileLoader(luaFileLoader); //Core.FileReader.AddReader(FileRead); }
public static extern IntPtr ERR_print_errors_cb(LogDelegate cb, IntPtr user);
protected Job(LogDelegate logFunc) { Active = true; Marked = true; Log = logFunc; }
/// <summary> /// Adds a logger instance to the server /// </summary> /// <returns>The server configuration.</returns> /// <param name="logger">The logger module to add.</param> public ServerConfig AddLogger(LogDelegate logger) { return(AddLogger(new Logging.FunctionLogger(logger))); }
/// <summary> /// Unregister the given log listener. /// </summary> /// <returns> /// <c>true</c>, if log listener was removed successfully, /// <c>false</c> otherwise. /// </returns> /// <param name="listener"> /// Listener, which should be removed. /// </param> /// <param name="clientData"> /// Pointer value which was used during the registration. /// </param> public static bool RemoveLogListener(LogDelegate listener, IntPtr clientData) { return(vlRemoveLogListener(listener, clientData)); }
private static extern bool vlRemoveLogListener( [MarshalAs(UnmanagedType.FunctionPtr)] LogDelegate listener, IntPtr clientData);
public CmdWindow() { delAddLog = new LogDelegate(Addlog); InitializeComponent(); }
public LogForwarder(LogLevel logLevel, [NotNull] ILog logger, [NotNull] LogDelegate logDelegate) { _logLevel = logLevel; _logger = logger ?? throw new ArgumentNullException(nameof(logger)); _logDelegate = logDelegate ?? throw new ArgumentNullException(nameof(logDelegate)); }
private Logger(LogLevel logLevel, LogDelegate logDelegate) { this.logLevel = logLevel; log = logDelegate; }
public void ComputeHulls(LogDelegate log, ProgressDelegate progress) { string strMeshAssetPath = ""; if (CreateMeshAssets) { strMeshAssetPath = UnityEditor.EditorUtility.SaveFilePanelInProject("Save mesh asset", "mesh_" + gameObject.name + this.GetInstanceID().ToString() + ".asset", "asset", "Please enter a file name to save the mesh asset to"); if (strMeshAssetPath.Length == 0) { return; } } MeshFilter theMesh = (MeshFilter)gameObject.GetComponent <MeshFilter>(); bool bForceNoMultithreading = ForceNoMultithreading; if (Algorithm == EAlgorithm.Legacy) { // Force no multithreading for the legacy method since sometimes it hangs when merging hulls bForceNoMultithreading = true; } DllInit(!bForceNoMultithreading); if (log != null) { SetLogFunctionPointer(Marshal.GetFunctionPointerForDelegate(log)); } else { SetLogFunctionPointer(IntPtr.Zero); } if (progress != null) { SetProgressFunctionPointer(Marshal.GetFunctionPointerForDelegate(progress)); } else { SetProgressFunctionPointer(IntPtr.Zero); } SConvexDecompositionInfoInOut info = new SConvexDecompositionInfoInOut(); int nMeshCount = 0; if (theMesh) { if (theMesh.sharedMesh) { info.uMaxHullVertices = (uint)(Mathf.Max(3, MaxHullVertices)); info.uMaxHulls = (uint)(Mathf.Max(1, MaxHulls)); info.fPrecision = 1.0f - Mathf.Clamp01(Precision); info.fBackFaceDistanceFactor = BackFaceDistanceFactor; info.uLegacyDepth = Algorithm == EAlgorithm.Legacy ? (uint)(Mathf.Max(1, LegacyDepth)) : 0; info.uNormalizeInputMesh = NormalizeInputMesh == true ? (uint)1 : (uint)0; info.uUseFastVersion = Algorithm == EAlgorithm.Fast ? (uint)1 : (uint)0; info.uTriangleCount = (uint)theMesh.sharedMesh.triangles.Length / 3; info.uVertexCount = (uint)theMesh.sharedMesh.vertexCount; if (DebugLog) { Debug.Log(string.Format("Processing mesh: {0} triangles, {1} vertices.", info.uTriangleCount, info.uVertexCount)); } Vector3[] av3Vertices = theMesh.sharedMesh.vertices; float fMeshRescale = 1.0f; if (NormalizeInputMesh == false && InternalScale > 0.0f) { av3Vertices = new Vector3[theMesh.sharedMesh.vertexCount]; float fMaxDistSquared = 0.0f; for (int nVertex = 0; nVertex < theMesh.sharedMesh.vertexCount; nVertex++) { float fDistSquared = theMesh.sharedMesh.vertices[nVertex].sqrMagnitude; if (fDistSquared > fMaxDistSquared) { fMaxDistSquared = fDistSquared; } } fMeshRescale = InternalScale / Mathf.Sqrt(fMaxDistSquared); if (DebugLog) { Debug.Log("Max vertex distance = " + Mathf.Sqrt(fMaxDistSquared) + ". Rescaling mesh by a factor of " + fMeshRescale); } for (int nVertex = 0; nVertex < theMesh.sharedMesh.vertexCount; nVertex++) { av3Vertices[nVertex] = theMesh.sharedMesh.vertices[nVertex] * fMeshRescale; } } if (DoConvexDecomposition(ref info, av3Vertices, theMesh.sharedMesh.triangles)) { if (info.nHullsOut > 0) { if (DebugLog) { Debug.Log(string.Format("Created {0} hulls", info.nHullsOut)); } DestroyHulls(); foreach (Collider collider in GetComponents <Collider>()) { collider.enabled = false; } m_aGoHulls = new GameObject[info.nHullsOut]; } else if (info.nHullsOut == 0) { if (log != null) { log("Error: No hulls were generated"); } } else { // -1 User cancelled } for (int nHull = 0; nHull < info.nHullsOut; nHull++) { SConvexDecompositionHullInfo hullInfo = new SConvexDecompositionHullInfo(); GetHullInfo((uint)nHull, ref hullInfo); if (hullInfo.nTriangleCount > 0) { m_aGoHulls[nHull] = new GameObject("Hull " + nHull); m_aGoHulls[nHull].transform.position = this.transform.position; m_aGoHulls[nHull].transform.rotation = this.transform.rotation; m_aGoHulls[nHull].transform.parent = this.transform; m_aGoHulls[nHull].layer = this.gameObject.layer; Vector3[] hullVertices = new Vector3[hullInfo.nVertexCount]; int[] hullIndices = new int[hullInfo.nTriangleCount * 3]; float fHullVolume = -1.0f; float fInvMeshRescale = 1.0f / fMeshRescale; FillHullMeshData((uint)nHull, ref fHullVolume, hullIndices, hullVertices); if (NormalizeInputMesh == false && InternalScale > 0.0f) { fInvMeshRescale = 1.0f / fMeshRescale; for (int nVertex = 0; nVertex < hullVertices.Length; nVertex++) { hullVertices[nVertex] *= fInvMeshRescale; hullVertices[nVertex] = Vector3.Scale(hullVertices[nVertex], transform.localScale); } } else { for (int nVertex = 0; nVertex < hullVertices.Length; nVertex++) { hullVertices[nVertex] = Vector3.Scale(hullVertices[nVertex], transform.localScale); } } Mesh hullMesh = new Mesh(); hullMesh.vertices = hullVertices; hullMesh.triangles = hullIndices; Collider hullCollider = null; fHullVolume *= Mathf.Pow(fInvMeshRescale, 3.0f); if (fHullVolume < MinHullVolume) { if (DebugLog) { Debug.Log(string.Format("Hull {0} will be approximated as a box collider (volume is {1:F2})", nHull, fHullVolume)); } MeshFilter meshf = m_aGoHulls[nHull].AddComponent <MeshFilter>(); meshf.sharedMesh = hullMesh; // Let Unity3D compute the best fitting box (it will use the meshfilter) hullCollider = m_aGoHulls[nHull].AddComponent <BoxCollider>() as BoxCollider; BoxCollider boxCollider = hullCollider as BoxCollider; boxCollider.center = hullMesh.bounds.center; boxCollider.size = hullMesh.bounds.size; if (CreateHullMesh == false) { if (Application.isEditor && Application.isPlaying == false) { DestroyImmediate(meshf); DestroyImmediate(hullMesh); } else { Destroy(meshf); Destroy(hullMesh); } } else { meshf.sharedMesh.RecalculateNormals(); meshf.sharedMesh.uv = new Vector2[hullVertices.Length]; } } else { if (DebugLog) { Debug.Log(string.Format("Hull {0} collider: {1} vertices and {2} triangles. Volume = {3}", nHull, hullMesh.vertexCount, hullMesh.triangles.Length / 3, fHullVolume)); } MeshCollider meshCollider = m_aGoHulls[nHull].AddComponent <MeshCollider>() as MeshCollider; meshCollider.sharedMesh = hullMesh; meshCollider.convex = true; hullCollider = meshCollider; if (CreateHullMesh) { MeshFilter meshf = m_aGoHulls[nHull].AddComponent <MeshFilter>(); meshf.sharedMesh = hullMesh; } if (CreateMeshAssets) { if (nMeshCount == 0) { if (progress != null) { progress("Creating mesh assets", 0.0f); } // Avoid some shader warnings hullMesh.RecalculateNormals(); hullMesh.uv = new Vector2[hullVertices.Length]; UnityEditor.AssetDatabase.CreateAsset(hullMesh, strMeshAssetPath); } else { if (progress != null) { progress("Creating mesh assets", info.nHullsOut > 1 ? (nHull / (info.nHullsOut - 1.0f)) * 100.0f : 100.0f); } // Avoid some shader warnings hullMesh.RecalculateNormals(); hullMesh.uv = new Vector2[hullVertices.Length]; UnityEditor.AssetDatabase.AddObjectToAsset(hullMesh, strMeshAssetPath); UnityEditor.AssetDatabase.ImportAsset(UnityEditor.AssetDatabase.GetAssetPath(hullMesh)); } } nMeshCount++; } if (hullCollider) { hullCollider.material = PhysMaterial; hullCollider.isTrigger = IsTrigger; if (hullInfo.nTriangleCount > LargestHullFaces) { LargestHullFaces = hullInfo.nTriangleCount; } if (hullInfo.nVertexCount > LargestHullVertices) { LargestHullVertices = hullInfo.nVertexCount; } } } } if (CreateMeshAssets) { UnityEditor.AssetDatabase.Refresh(); } } else { if (log != null) { log("Error: convex decomposition could not be completed due to errors"); } } } else { if (log != null) { log("Error: " + this.name + " has no mesh"); } } } else { if (log != null) { log("Error: " + this.name + " has no mesh"); } } DllClose(); }
static void Main(string[] args) { AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException; if (args.Length > 0) { switch (args[0]) { case "-c": Log = Console.WriteLine; var svc = new Service(); svc.TestRun(args.Skip(1).ToArray()); Console.WriteLine("Running service..."); Console.WriteLine("Press any key to exit."); Console.ReadKey(); svc.Stop(); break; case "-i": case "-u": var ins = new AssemblyInstaller(typeof(Program).Assembly.Location, new string[0]) { UseNewContext = true }; if (args[0] == "-i") ins.Install(null); else ins.Uninstall(null); ins.Commit(null); break; case "-s": new ServiceController(PublicName).Start(); break; default: Console.Write(@"Unknown switch. Use one of these: -c Console: use for test run -i Install service -u Uninstall service -s Start service "); break; } } else { Log = LogToFile; RotateLog(); ServiceBase.Run(new Service()); } }