using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace IACommService4CSharp { enum LevelMask_t { LOG_LEVEL_FATAL = 0x00000001, LOG_LEVEL_ERROR = 0x00000002, LOG_LEVEL_WARN = 0x00000004, LOG_LEVEL_INFO = 0x00000008 } enum CategoryMask_t { LOG_CATEGORY_SYSTEM = 0x00000001, LOG_CATEGORY_CONNECT = 0x00000002, LOG_CATEGORY_READ = 0x00000004, LOG_CATEGORY_WRITE = 0x00000008, LOG_CATEGORY_SUBSCRIBE = 0x00000010 } public class LogConfig_t { private static readonly string Service_Log_Enable = "LogEnable"; private static readonly string Service_Log_Path = "LogPath"; private static readonly string Service_Log_DateFormat = "LogDateFormat"; private static readonly string Service_Log_MaxFileSize = "LogMaxFileSize"; private static readonly string Service_Log_MaxBackupIndex = "LogMaxBackupIndex"; private static readonly string Service_Log_LevelMask = "LogLevelMask"; private static readonly string Service_Log_CategoryMask = "LogCategoryMask"; public LogConfig_t() { Enable = true; Path = "./"; DateFormat = "%Y-%m-%d %H:%M:%S.%q"; MaxFileSize = 524288; MaxBackupIndex = 5; LevelMask = Convert.ToUInt32(LevelMask_t.LOG_LEVEL_FATAL | LevelMask_t.LOG_LEVEL_ERROR | LevelMask_t.LOG_LEVEL_WARN | LevelMask_t.LOG_LEVEL_INFO); CategoryMask = Convert.ToUInt32(CategoryMask_t.LOG_CATEGORY_SYSTEM | CategoryMask_t.LOG_CATEGORY_CONNECT); } ~LogConfig_t() { } public bool Enable { get; set; } public string Path { get; set; } public string DateFormat { get; set; } public uint MaxFileSize { get; set; } public uint MaxBackupIndex { get; set; } public uint LevelMask { get; set; } public uint CategoryMask { get; set; } //Internal use public Dictionary GetConfig() { Dictionary logConfig = new Dictionary(); logConfig.Add(Service_Log_Enable, Enable ? "true" : "false"); logConfig.Add(Service_Log_Path, Path); logConfig.Add(Service_Log_DateFormat, DateFormat); logConfig.Add(Service_Log_MaxFileSize, Convert.ToString(MaxFileSize)); logConfig.Add(Service_Log_MaxBackupIndex, Convert.ToString(MaxBackupIndex)); logConfig.Add(Service_Log_LevelMask, Convert.ToString(LevelMask)); logConfig.Add(Service_Log_CategoryMask, Convert.ToString(CategoryMask)); return logConfig; } } }