예제 #1
0
        public void OnLogMessageReceived(AILogType type, string parent, string message)
        {
            if (type == AILogType.Trace && !traceEnabled)
            {
                return;
            }
            if (type == AILogType.Info && !infoEnabled)
            {
                return;
            }

            var t = type switch
            {
                AILogType.Info => "INFO",
                AILogType.Trace => "TRACE",
                AILogType.KeyInfo => "KEY",
                _ => "UNDEF"
            };

            logContainer.Add(new Label($"{System.DateTime.Now} {t} {parent}: {message}"));
        }
    }
예제 #2
0
        public void Log <T>(AILogType type, T parent, string message)
        {
            string prefix = typeof(T).Name;

            observers.ForEach(o => o.OnLogMessageReceived(type, prefix, message));

            if (LogLevel == LogLevels.None)
            {
                return;
            }

            bool shouldLog = false;

            switch (type)
            {
            case AILogType.Trace:
                shouldLog = LogLevel == LogLevels.Trace;
                break;

            case AILogType.Info:
                shouldLog = LogLevel == LogLevels.Debug || LogLevel == LogLevels.Trace;
                break;

            case AILogType.KeyInfo:
                shouldLog = true;
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(type), type, null);
            }

            if (shouldLog)
            {
                Debug.Log($"{prefix}: {message}");
            }
        }