12345678910111213141516171819202122232425262728293031323334353637383940 |
- using System;
- using UnityEngine;
- namespace Logging
- {
- public class Logging : MonoBehaviour
- {
- public float writeInterval = 1f;
- private float prevLogTimestamp = 0f;
- private FileLogger logger;
- private void Awake()
- {
- gameObject.SetActive(GameManager.LOG_TO_FILE);
- }
- private void Start()
- {
- logger = FileLogger.Instance;
- }
- private async void Update()
- {
- var time = Time.time;
- var dif = time - prevLogTimestamp;
- if (dif >= writeInterval)
- {
- await logger.UpdateRegisteredLogs();
- prevLogTimestamp = time;
- }
- }
- private async void OnDestroy()
- {
- await logger.UpdateRegisteredLogs();
- FileLogger.DestroyInstance();
- }
- }
- }
|