public void CreateLogger(StatLogType type) { int periodTime = 5; switch (type) { case StatLogType.COST: case StatLogType.LOGIN: case StatLogType.UPGRADE: case StatLogType.REGISTER: case StatLogType.RECHARGE: case StatLogType.ONLINE: case StatLogType.LOGOUT: case StatLogType.AU: case StatLogType.CONSUME: periodTime = 5; break; case StatLogType.LISTENCHAT: case StatLogType.EQUIP: periodTime = 10; break; } StatLogger logger = new StatLogger(serverKey, prefix, periodTime, type); if (LoggerList.ContainsKey(type)) { LoggerList[type] = logger; } else { LoggerList.Add(type, logger); } }
public void Write(string log, StatLogType type) { StatLogger logger = null; if (LoggerList.TryGetValue(type, out logger)) { logger.Write(log, type); } }
public StatLogger(string server_key, string prefix, int refresh_time, StatLogType type) { this.serverKey = server_key; this.refreshTime = refresh_time; // prefix = serverName_param // e.g. ZoneServer_1_1 ManagerServcer_1 BarrackServer_2 this.prefix = prefix; this.type = type; if (IsSpecStatLogType(type)) { Dir = "c:/SpecStatLog/"; } else { Dir = "c:/StatLog/"; } CreateNewLogFile(); }
private bool IsSpecStatLogType(StatLogType type) { switch (type) { case StatLogType.COST: case StatLogType.LOGIN: case StatLogType.UPGRADE: case StatLogType.REGISTER: case StatLogType.RECHARGE: case StatLogType.ONLINE: case StatLogType.LOGOUT: case StatLogType.AU: return(false); default: return(true); } }
public void Write(string log, StatLogType type) { try { log += '|' + serverKey + '_' + type.ToString(); //tw.WriteLine(log); } catch (Exception e) { Log.Warn(e.ToString()); } /* * writeLength += log.Length; * if (writeLength >= fileSize) * { * tw.Close(); * CreateNewLogFile(); * } */ }