Esempio n. 1
0
        /// <summary>
        /// Log a warning
        /// </summary>
        /// <param name="message">The message of the warning</param>
        public static void Warning(string message)
        {
            var obj = new LogObject
            {
                Level      = LogLevel.Warning,
                Message    = message,
                Notifiable = true,
                Timestamp  = DateTime.Now
            };

            Log(obj);
        }
Esempio n. 2
0
        /// <summary>
        /// Logs to the set <see cref="LogFilePath"/>. If no file is set, an exception will be thrown.
        /// The log will raise the <see cref="LogEntered"/> event that will be experienced evironment wide.
        /// </summary>
        /// <param name="log">The <see cref="LogObject"/> to enter.</param>
        public static void Log(LogObject log)
        {
            if (LogFilePath == null)
            {
                throw new NullReferenceException("No log file was specified");
            }
            var list = new List <string>
            {
                log.ToString()
            };

            File.AppendAllLines(LogFilePath, list);
            if (log.Notifiable)
            {
                LogEntered?.Invoke(log);
            }
        }