Example #1
0
    private static void WriteFile(object sender, LogType type, string source, string message)
    {
        List <object> list = new List <object>();

        list.Add(source);
        list.Add(message);
        HttpContext current = HttpContext.Current;

        if (current != null)
        {
            list.Add((current.User != null) ? current.User.Identity.Name : "");
            list.Add(current.Request.UserHostAddress);
            list.Add(current.Request.UserAgent);
            list.Add((current.Request.UrlReferrer != (Uri)null) ? current.Request.UrlReferrer.Authority : "");
        }
        CommonLib.Log.LogType type2;
        switch (type)
        {
        case LogType.Debug:
            type2 = CommonLib.Log.LogType.DEBUG;
            break;

        case LogType.Error:
            type2 = CommonLib.Log.LogType.ERROR;
            break;

        case LogType.Warning:
            type2 = CommonLib.Log.LogType.WARNING;
            break;

        case LogType.Information:
            type2 = CommonLib.Log.LogType.NORMAL;
            break;

        default:
            type2 = CommonLib.Log.LogType.NORMAL;
            break;
        }
        CustomLog.Write(sender, type2, list.ToArray());
    }