private void DgvLog_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e) { InternalLog il = virtualData[e.RowIndex]; switch (il.Level) { case RealPlugin.DebugLevelEnum.Verbose: e.CellStyle.BackColor = Color.LightGray; e.CellStyle.ForeColor = Color.Black; break; case RealPlugin.DebugLevelEnum.Info: e.CellStyle.BackColor = Color.White; e.CellStyle.ForeColor = Color.Black; break; case RealPlugin.DebugLevelEnum.Warning: e.CellStyle.BackColor = Color.Yellow; e.CellStyle.ForeColor = Color.Black; break; case RealPlugin.DebugLevelEnum.Error: e.CellStyle.BackColor = Color.Red; e.CellStyle.ForeColor = Color.Yellow; break; } e.FormattingApplied = true; }
private void OnSendCompleted(object sender, SocketAsyncEventArgs e) { foreach (var packet in m_PacketsToSendList) { Handler.OnRecycle(packet); } // Sending failed. if (e.SocketError != SocketError.Success) { InternalLog.DebugFormat("[TcpChannel OnSendCompleted] Failure, SocketError={0}.", e.SocketError); Close(); OnError("Sending data failed. Error data is a SocketError.", e.SocketError); return; } InternalLog.DebugFormat("[TcpChannel OnSendCompleted] Success, bytesTransferred={0}.", e.BytesTransferred); lock (m_PacketsToSend) { if (m_PacketsToSend.Count <= 0) { Interlocked.Exchange(ref m_IsSending, 0); return; } CopyPacketsToSend(); } DoSend(); }
public override void Run(string[] args) { // Log any unhandled exception. AppDomain.CurrentDomain.UnhandledException += (s, e) => { var exception = e.ExceptionObject as Exception; InternalLog.Error(LogTag, $"Unhandled exception: {exception}"); }; // Parse engine arguments passed from the tool. This should be reworked. for (int i = args.Length - 1; i >= 0; i--) { var arg = args[i].Trim('\''); if (arg.StartsWith("FLUTTER_ENGINE_ARGS")) { var engineArgs = arg.Substring(arg.IndexOf(' ')); InternalLog.Debug(LogTag, "Running with: " + engineArgs); // A regex is used here to correctly parse "quoted" strings. // TODO: Avoid using Linq to reduce the memory pressure. EngineArgs.AddRange(Regex.Matches(engineArgs, @"[\""].+?[\""]|[^ ]+") .Cast <Match>() .Select(x => x.Value.Trim('"'))); break; } } base.Run(args); }
protected override void Update(TimeStruct timeStruct) { switch (Status) { case ResourceCacheStatus.Loading: if (!string.IsNullOrEmpty(m_LoadingTask.ErrorMessage)) { ErrorMessage = m_LoadingTask.ErrorMessage; InternalLog.DebugFormat("[ResourceCache Update] {0} loading fail", Path); FailAndNotify(); } else if (m_LoadingTask.IsDone) { ResourceObject = m_LoadingTask.ResourceObject; InternalLog.DebugFormat("[ResourceCache Update] {0} loading success", Path); SucceedAndNotify(); } break; default: break; } }
internal override void Init() { InternalLog.DebugFormat("[ResourceCache Reuse] {0}", Path); Owner.m_ResourcePathsNotReadyOrFailure.Add(Path); Status = ResourceCacheStatus.WaitingForSlot; Owner.m_WaitingForSlotResourceCaches.Add(this); }
internal override void Init() { InternalLog.DebugFormat("[AssetCache Init] {0}", Path); m_LastLoadingProgress = 0f; Owner.m_AssetPathsNotReadyOrFailure.Add(Path); var resourceCache = Owner.EnsureResourceCache(ResourcePath); resourceCache.IncreaseRetainCount(); if (DependencyAssetPaths.Count <= 0) { InternalLog.DebugFormat("[AssetCache Init] {0} no dep. observe resource.", Path); Status = AssetCacheStatus.WaitingForResource; resourceCache.AddObserver(this); return; } Status = AssetCacheStatus.WaitingForDeps; foreach (var depAssetPath in DependencyAssetPaths) { var depAssetCache = Owner.EnsureAssetCache(depAssetPath); depAssetCache.IncreaseRetainCount(); depAssetCache.AddObserver(this); } DFSAddResourceRetainCounts(resourceCache); }
protected void InitInternal(Config config) { if (config == null) { throw new ArgumentNullException("config"); } Config = config; InternalLog = new InternalLog(this); PrepareDataHelper = new PrepareDataHelper(this); var programName = Tools.GetProgramName(); AccessToken = new AccessToken() { SecretKey = config.Access.SecretKey, Program = programName }; GetFolderComponentTypeControl(); // чтобы заполнить кэш WebLogManager = new WebLogManager(this); EventManager = new EventManager(this); Start(); }
protected override void Update(TimeStruct timeStruct) { switch (Status) { case AssetCacheStatus.Loading: if (!string.IsNullOrEmpty(m_LoadingTask.ErrorMessage)) { ErrorMessage = m_LoadingTask.ErrorMessage; InternalLog.DebugFormat("[AssetCache Update] {0} loading fail.", Path); FailAndNotify(); } else if (m_LoadingTask.IsDone) { AssetObject = m_LoadingTask.AssetObject; InternalLog.DebugFormat("[AssetCache Update] {0} loading success.", Path); SucceedAndNotify(); } else { if (LoadingProgress != m_LastLoadingProgress) { m_LastLoadingProgress = LoadingProgress; ProgressAndNotify(); } } break; } }
private bool TryParseReadWriteIndexOrFail() { // If the read-write index doesn't exist. Just keep 'ReadWriteIndex' empty as it is. if (!File.Exists(m_Owner.ReadWriteIndexPath)) { return(true); } try { using (var stream = File.OpenRead(m_Owner.ReadWriteIndexPath)) { using (var br = new BinaryReader(stream)) { DeserializeAssetIndex(br, ReadWriteIndex); } } } catch (Exception e) { InternalLog.Warning($"Cannot parse the index file with exception '{e}'. Will try to clean up read-write path."); ReadWriteIndex.Clear(); return(!File.Exists(m_Owner.ReadWriteIndexPath) || m_Owner.TryCleanUpReadWritePathOrFail(Fail)); } return(true); }
public static void Error( string message, [CallerFilePath] string file = "", [CallerMemberName] string func = "", [CallerLineNumber] int line = 0) { InternalLog.Error(LogTag, message, file, func, line); }
public void OnClearList(object sender, EventArgs e) { InternalLog.Reset(); store.Clear(); UpdateErrorsNum(); UpdateWarningsNum(); UpdateMessagesNum(); UpdateDebugNum(); }
public static ILog NewLog(string message, LogType logType = LogType.Info, DateTime?dateTime = null) { if (dateTime.HasValue) { return(InternalLog.New(message, logType, dateTime.Value)); } else { return(InternalLog.New(message, logType)); } }
public override void OnShutdown() { InternalLog.Debug("[NetModule ShutDown] channel count is " + m_Channels.Count); foreach (var channel in m_Channels) { channel.Close(); } m_Channels.Clear(); base.OnShutdown(); }
internal virtual void ReduceRetainCount() { if (m_RetainCount <= 0) { throw new InvalidOperationException(Utility.Text.Format("Reducing retain count to negative, on '{0}' ({1}).", Path, GetType().Name)); } --m_RetainCount; InternalLog.DebugFormat("[{0} ReduceRetainCount] '{2}' to {1}", GetType().Name, m_RetainCount, Path); }
public override void Run(string[] args) { // Log any unhandled exception. AppDomain.CurrentDomain.UnhandledException += (s, e) => { var exception = e.ExceptionObject as Exception; InternalLog.Error(LogTag, $"Unhandled exception: {exception}"); }; base.Run(args); }
internal override void OnSlotReady() { if (Status != ResourceCacheStatus.WaitingForSlot) { throw new InvalidOperationException($"Oops! '{nameof(OnSlotReady)}' cannot be called on status '{Status}'."); } m_LoadingTask = Owner.RunResourceLoadingTask(Path, ShouldLoadFromReadWritePath ? Owner.ReadWritePath : Owner.InstallerPath); InternalLog.DebugFormat("[ResourceCache Update] {0} start loading", Path); Status = ResourceCacheStatus.Loading; StartTicking(); }
protected override void OnCreate() { base.OnCreate(); // Read engine arguments passed from the tool. ParseEngineArgs(); InternalLog.Info(LogTag, $"switches: {string.Join(" ", EngineArgs)}"); // Get the screen size of the currently running device. if (!Information.TryGetValue("http://tizen.org/feature/screen.width", out int width) || !Information.TryGetValue("http://tizen.org/feature/screen.height", out int height)) { InternalLog.Error(LogTag, "Could not obtain the screen size."); return; } var windowProperties = new FlutterWindowProperties { width = width, height = height }; // Get paths to resources required for launch. string resPath = Current.DirectoryInfo.Resource; string assetsPath = $"{resPath}/flutter_assets"; string icuDataPath = $"{resPath}/icudtl.dat"; string arch = RuntimeInformation.ProcessArchitecture switch { Architecture.X86 => "x86", Architecture.X64 => "x64", Architecture.Arm => "arm", Architecture.Arm64 => "aarch64", _ => "", }; string aotLibPath = $"{resPath}/../lib/{arch}/libapp.so"; using var switches = new StringArray(EngineArgs); var engineProperties = new FlutterEngineProperties { assets_path = assetsPath, icu_data_path = icuDataPath, aot_library_path = aotLibPath, switches = switches.Handle, switches_count = (uint)switches.Length, }; Handle = FlutterCreateWindow(ref windowProperties, ref engineProperties); if (Handle.IsInvalid) { throw new Exception("Could not launch a Flutter application."); } }
public static void WriteLine(String Text, SortedDictionary <int, Color> ColourArgs) { String Time = "(" + System.DateTime.Now.ToLongTimeString() + ")"; if (pHasConsole) { Console.WriteLine(Time + " " + Text); } Text = Text.Replace('[', '(').Replace(']', ')'); ArrayList Store = new ArrayList(); Store.Add(Color.Yellow); Store.Add(Time + " "); if (ColourArgs != null) { Color RollingColour = Color.White; int LastI = 0; foreach (int i in ColourArgs.Keys) { if (i - LastI > 0) { String Seg = Text.Substring(LastI, i - LastI); Store.Add(RollingColour); Store.Add(Seg); } RollingColour = ColourArgs[i]; LastI = i; } if (LastI < Text.Length) { Store.Add(RollingColour); Store.Add(Text.Remove(0, LastI)); } } else { Store.Add(Color.White); Store.Add(Text); } object[] ThisEntry = Store.ToArray(); InternalLog.Add(ThisEntry); ConsoleWrittenTo?.Invoke(Text); try { Monitor.Enter(CWriteLockObj); pLastLogLine = Text; } finally { Monitor.Exit(CWriteLockObj); } }
private void OnError(string errorMessage, SocketError?socketError) { InternalLog.Debug("[TcpChannel OnError] Start."); try { Handler.OnError(errorMessage, socketError == null ? null : (object)socketError.Value); } catch { // ignored } finally { InternalLog.Debug("[TcpChannel OnError] End."); } }
public void Close() { lock (m_StateLock) { InternalLog.Debug("[TcpChannel OnClose] Start."); if (m_State == NetChannelState.Unknown || m_State == NetChannelState.Closed || m_State == NetChannelState.Closing || m_State == NetChannelState.Disconnected) { return; } m_State = NetChannelState.Closing; } Clear(); Interlocked.Exchange(ref m_IsSending, 0); m_SendingEventArgs.Completed -= OnSendCompleted; m_ReceiveEventArgs.Completed -= OnReceiveCompleted; m_ConnectionEventArgs.Completed -= OnConnectionComplete; m_ReceiveStream.Dispose(); m_SendingStream.Dispose(); InternalLog.Debug("[TcpChannel OnClose] Before socket shutdown and close."); try { m_Socket.Shutdown(SocketShutdown.Both); m_Socket.Close(); } catch { // ignored } finally { InternalLog.Debug("[TcpChannel OnClose] finally block."); m_Socket = null; lock (m_StateLock) { m_State = NetChannelState.Closed; } InternalLog.Debug("[TcpChannel OnClose] End."); } }
internal override void Reset() { InternalLog.DebugFormat("[AssetCache Reset] {0}", Path); m_CopiedAssetObservers.Clear(); m_AssetObservers.Clear(); m_CopiedAssetAccessors.Clear(); m_AssetAccessors.Clear(); StopTicking(); StopAndResetLoadingTask(); AssetObject = null; foreach (var depAssetPath in DependencyAssetPaths) { var depAssetCache = Owner.EnsureAssetCache(depAssetPath); depAssetCache.RemoveObserver(this); depAssetCache.ReduceRetainCount(); } var resourceCache = Owner.EnsureResourceCache(ResourcePath); resourceCache.RemoveObserver(this); resourceCache.ReduceRetainCount(); foreach (var dependencyResourcePath in m_DependencyResourcePaths) { var dependencyResourceCache = Owner.m_ResourceCaches[dependencyResourcePath]; #if DEBUG if (dependencyResourceCache.Status == ResourceCacheStatus.None) { throw new InvalidOperationException($"Resource cache of path [{dependencyResourcePath}] is invalid."); } #endif dependencyResourceCache.ReduceRetainCount(); } m_DependencyResourcePaths.Clear(); DependencyAssetPaths = null; Status = AssetCacheStatus.None; Owner.m_AssetPathsNotReadyOrFailure.Remove(Path); m_DependencyAssetReadyCount = 0; ResourcePath = null; IsScene = false; m_LastLoadingProgress = 0; base.Reset(); }
protected ApiServiceWrapper CreateApiService(AccessToken accessToken) { try { var dtoService = CreateDtoService(Config.Access.AccountName); var apiService = new ApiService(dtoService, accessToken); return(new ApiServiceWrapper(this, apiService)); } catch (Exception exception) { InternalLog.Error("Не удалось настроить веб-сервис для аккаунта [" + Config.Access.AccountName + "]", exception); // отдадим заглушку var apiService = new FakeApiService(); apiService.SetAccessToken(accessToken); return(new ApiServiceWrapper(this, apiService)); } }
public void AddObserver(AssetCache resourceObserver) { if (Status == ResourceCacheStatus.Ready) { InternalLog.DebugFormat("[ResourceCache AddObserver] Path={0}, AssetPath={1} direct success", Path, resourceObserver.Path); resourceObserver.OnLoadResourceSuccess(Path, ResourceObject); } else if (Status == ResourceCacheStatus.Failure) { InternalLog.DebugFormat("[ResourceCache AddObserver] Path={0}, AssetPath={1} direct fail", Path, resourceObserver.Path); resourceObserver.OnLoadResourceFailure(Path, ErrorMessage); } else { m_ResourceObservers.Add(resourceObserver); } }
private void DgvLog_CellValueNeeded(object sender, DataGridViewCellValueEventArgs e) { InternalLog il = virtualData[e.RowIndex]; switch (e.ColumnIndex) { case 0: e.Value = RealPlugin.FormatDateTime(il.Timestamp); break; case 1: e.Value = I18n.Translate("internal/Plugin/loglevel" + il.Level.ToString(), "{0}", il.Level.ToString()); break; case 2: e.Value = il.Message; break; } }
public virtual void Setup() { // All this initialization was copied/pasted from IdeApp.Run. Hopefully i copied enough of it. if (!Initialized) { Initialized = true; //ensure native libs initialized before we hit anything that p/invokes MonoDevelop.Core.Platform.Initialize(); // Set a synchronization context for the main gtk thread SynchronizationContext.SetSynchronizationContext(new GtkSynchronizationContext()); IdeApp.Customizer = new MonoDevelop.Ide.Extensions.IdeCustomizer(); DispatchService.Initialize(); InternalLog.Initialize(); DesktopService.Initialize(); ImageService.Initialize(); IdeApp.Initialize(new NullProgressMonitor()); } }
internal override void OnSlotReady() { if (Status != AssetCacheStatus.WaitingForSlot) { throw new InvalidOperationException($"Oops! '{nameof(OnSlotReady)}' cannot be called on status '{Status}'."); } if (IsScene) { SucceedAndNotify(); } else { m_LoadingTask = Owner.RunAssetLoadingTask(Path, Owner.EnsureResourceCache(ResourcePath).ResourceObject); InternalLog.DebugFormat("[AssetCache Update] {0} start loading.", Path); Status = AssetCacheStatus.Loading; StartTicking(); } }
private void ReleaseUnusedResourceCaches() { if (m_UnretainedResourceCaches.Count <= 0) { return; } bool releaseAll = true; // We need all resources (AssetBundles) that have dependencies between each other to be released/unloaded at the same time; // Otherwise, there will be occasional but confusing asset missing issues. // Here we use the simplest strategy. Once all unretained resources can be released safely, we do it all. Otherwise, we don't release any. foreach (var resourceCache in m_UnretainedResourceCaches) { if (!resourceCache.CanRelease()) { InternalLog.Info($"[AssetModule.Loader ReleaseUnusedResourceCaches] Cannot release {resourceCache.Path}. Drop."); releaseAll = false; break; } } if (!releaseAll) { return; } InternalLog.Info($"[AssetModule.Loader ReleaseUnusedResourceCaches] Release {m_UnretainedResourceCaches.Count} resources."); foreach (var resourceCache in m_UnretainedResourceCaches) { // if (resourceCache.Status.ToString().StartsWith("Waiting")) // { // InternalLog.Warning($"{resourceCache.Status}, {resourceCache.Path}"); // } m_ResourceCaches.Remove(resourceCache.Path); m_WaitingForSlotResourceCaches.Remove(resourceCache); resourceCache.Reset(); m_ResourceCachePool.Release(resourceCache); } m_UnretainedResourceCaches.Clear(); }
internal override void Reset() { InternalLog.DebugFormat("[ResourceCache Reset] {0}", Path); m_CopiedResourceObservers.Clear(); m_ResourceObservers.Clear(); StopTicking(); StopAndResetLoadingTask(); if (ResourceObject != null) { Owner.ResourceDestroyer.Destroy(ResourceObject); } ResourceObject = null; ShouldLoadFromReadWritePath = false; Status = ResourceCacheStatus.None; Owner.m_ResourcePathsNotReadyOrFailure.Remove(Path); base.Reset(); }
protected DtoServiceProxy CreateDtoService(string accountName) { if (string.IsNullOrEmpty(accountName)) { throw new ResponseCodeException(ResponseCode.EmptyAccountName, "Не указан AccountName"); } Uri apiUrl = null; if (!string.IsNullOrEmpty(Config.Access.Url)) { try { apiUrl = new Uri(Config.Access.Url); } catch (UriFormatException exception) { throw new ResponseCodeException(ResponseCode.ApiUrlFormatError, "Неверный формат адреса Api: " + exception.Message); } } else { try { apiUrl = ApiHelper.GetApiUrl(accountName); } catch (UriFormatException exception) { throw new ResponseCodeException(ResponseCode.AccountNameFormatError, "Неверный формат имени аккаунта: " + exception.Message); } } InternalLog.Info("ApiUrl: " + apiUrl.AbsoluteUri); var dtoService = new DtoServiceProxy(apiUrl); return(dtoService); }
private void ParseEngineArgs() { string packageId = Current.ApplicationInfo.PackageId; string tempPath = $"/home/owner/share/tmp/sdk_tools/{packageId}.rpm"; if (!File.Exists(tempPath)) { return; } try { var lines = File.ReadAllText(tempPath).Trim().Split("\n"); if (lines.Length > 0) { EngineArgs.AddRange(lines); } File.Delete(tempPath); } catch (Exception ex) { InternalLog.Warn(LogTag, $"Error while processing a file:\n{ex}"); } }