Пример #1
0
        /// <summary>
        /// Return log file as string
        /// </summary>
        /// <param name="lines">lines cound from the end of log</param>
        /// <param name="format">format unixtime to readable date?</param>
        /// <returns></returns>
        public string GetLog(int lines, bool format = true)
        {
            var log = _server.getLog(0, lines);

            var logText = new StringBuilder();

            // iterate from the end
            for (int i = log.Length - 1; i >= 0; i--)
            {
                var date = (format)
                    ? _unixTimeStampToDateTime(log[i].timestamp).ToString()
                    : log[i].timestamp.ToString();
                logText.AppendLine(string.Format("[{0}] {1}", date, log[i].txt));
            }

            return(logText.ToString());
        }