Esempio n. 1
0
 /// <summary>
 /// 保存日志记录
 /// </summary>
 /// <param name="ex"></param>
 private static void DoWrite(SysLogType logType, string msg, Exception ex)
 {
     try
     {
         lock (_lock)
         {
             string filepath = FGA_NUtility.ConfigHelper.GetConfigValue("LogPath");
             if (string.IsNullOrEmpty(filepath))
             {
                 return;
             }
             filepath = filepath.EndsWith("\\") ? filepath : (filepath + "\\");
             if (!Directory.Exists(filepath))
             {
                 Directory.CreateDirectory(filepath);
             }
             string        fileName = filepath + DateTime.Now.ToString("yyyyMMdd") + ".log";
             StringBuilder sb       = new StringBuilder();
             sb.AppendLine("-----------------------------------------------------------------------------------");
             sb.AppendLine(">>" + logType.ToString() + "<<      " + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
             sb.AppendLine("-----------------------------------------------------------------------------------");
             if (!string.IsNullOrEmpty(msg))
             {
                 sb.AppendLine(msg);
             }
             if (ex != null)
             {
                 sb.AppendLine(ex.ToString());
             }
             File.AppendAllText(fileName, sb.ToString());
         }
     }
     catch { }
 }
Esempio n. 2
0
 public static SysLog Create(SysLogType logType, string url, string userId, string userIP, object objectId, object objectData, string memo)
 {
     return(new SysLog {
         LogType = logType.ToString(),
         Url = url,
         UserIP = userIP,
         ObjectId = objectId != null?objectId.ToString() : string.Empty,
                        ObjectData = SerializeData(objectData),
                        ObjectType = objectData != null?objectData.GetType().FullName : string.Empty,
                        Memo = memo,
                        Builder = userId,
                        BuildTime = DateTime.Now
     });
 }
Esempio n. 3
0
 /// <summary>
 /// 记录系统日志
 /// </summary>
 public void WriteSysLogToDB(string strContent, SysLogType logtype = SysLogType.normal)
 {
     try
     {
         using (wxEntities context = new wxEntities())
         {
             T_SysLogs _log = context.T_SysLogs.Create();
             _log.SysLogId   = Guid.NewGuid().ToString("N");
             _log.SysContent = strContent;
             _log.LogType    = logtype.ToString();
             _log.CreateTime = DateTime.Now;
             context.T_SysLogs.Add(_log);
             context.SaveChanges();
         }
     }
     catch
     {
     }
 }
    public static void AddLog( SysLogType _type , string _AddLog )
    {
        if( false == m_Active )
            return ;

        string fullLogString = Time.timeSinceLevelLoad.ToString() + ":"
            + _type.ToString() + ":"
            + _AddLog ;

        if( true == m_KeepWrite )
        {

            if( null != m_SW )
            {
                // Debug.Log( "m_SW.WriteLine( fullLogString ) ;" + fullLogString ) ;
                m_SW.WriteLine( fullLogString ) ;

            }
        }
        else
            m_Logs.Add( fullLogString ) ;
    }