123456789101112131415161718192021222324252627282930313233343536 |
- using System.Collections.Generic;
- using System.Linq;
- using System.Reflection;
- using UnityEngine;
- namespace Logging
- {
- public abstract class SensorDataLogger<T> : MonoBehaviour, ILogable, ISerializableLog<T>
- {
- public abstract string Key { get; }
- public IEnumerable<string> HeaderNames => typeof(T).GetFields(BindingFlags.Instance | BindingFlags.NonPublic).Select((f) => f.Name);
- public IEnumerable<IEnumerable<string>> BufferLines => Buffer;
- protected List<string[]> Buffer;
- public virtual void Awake()
- {
- gameObject.SetActive(GameManager.LOG_TO_FILE);
- }
- public virtual async void Start()
- {
- Buffer = new List<string[]>();
- await FileLogger.Instance.RegisterLogable(this);
- }
-
- public void ClearBuffer()
- {
- Buffer.Clear();
- }
- public abstract void Log(T value);
- public abstract IEnumerable<T> ReadLog(IEnumerable<IEnumerable<string>> lines);
- }
- }
|