private void Awake() { DefaultLogger.AddWriter(new UnityMessageWriter(new SimpleMessageFormatter())); _isEditor = Application.isEditor; _stream = new PatcherLogStream(); _tempFile = new PatcherTemporaryLogFile(); _registerTriggers = new PatcherLogRegisterTriggers(); _storage = new PatcherLogStorage(); _sentryRegistry = new PatcherLogSentryRegistry(); // Automatically call dispose on those objects when OnDestroy is called. _stream.AddTo(this); _tempFile.AddTo(this); _registerTriggers.AddTo(this); _stream.Messages.Subscribe(_tempFile.WriteLine).AddTo(this); _registerTriggers.ExceptionTrigger.Subscribe(e => { if (_isEditor && IgnoreEditorErrors) { return; } _sentryRegistry.RegisterWithException(e, _storage.Guid.ToString()); }) .AddTo(this); _registerTriggers.ExceptionTrigger.Throttle(TimeSpan.FromSeconds(5)) .Subscribe(e => { if (_isEditor && IgnoreEditorErrors) { return; } _tempFile.Flush(); StartCoroutine(_storage.SendLogFileCoroutine(_tempFile.FilePath)); }).AddTo(this); }