Example #1
0
        private void SaveLogToFile(AmeisenLogEntry entry)
        {
            if (!Directory.Exists(logPath))
            {
                Directory.CreateDirectory(logPath);
            }

            File.AppendAllText(logPath + logName, entry.ToString() + Environment.NewLine);
        }
Example #2
0
        /// <summary>
        /// Add an entry to the log
        /// </summary>
        /// <param name="loglevel">LogLevel of this Log-Message</param>
        /// <param name="msg">...</param>
        /// <param name="self">Class that calls it / string with class name</param>
        /// <param name="functionName">
        /// Function name that this is called by, no need to set this manually
        /// </param>
        /// <returns>The AmeisenLogEntry</returns>
        public AmeisenLogEntry Log(LogLevel loglevel, string msg, object self, [CallerMemberName] string functionName = "")
        {
            AmeisenLogEntry logEntry = new AmeisenLogEntry
            {
                loglevel     = loglevel,
                id           = logcount,
                timestamp    = DateTime.Now.ToLongTimeString(),
                msg          = msg,
                originClass  = self,
                functionName = functionName
            };

            if (loglevel >= activeLogLevel)
            {
                logcount++;
                entries.Enqueue(logEntry);
            }
            return(logEntry);
        }