diff --git a/src/BiliLite.UWP/App.xaml.cs b/src/BiliLite.UWP/App.xaml.cs
index 2c0706a6..ff13ea55 100644
--- a/src/BiliLite.UWP/App.xaml.cs
+++ b/src/BiliLite.UWP/App.xaml.cs
@@ -58,7 +58,7 @@ private void SynchronizationContext_UnhandledException(object sender, AysncUnhan
e.Handled = true;
try
{
- logger.Log("程序运行出现错误", LogType.ERROR, e.Exception);
+ logger.Log("程序运行出现错误", LogType.Error, e.Exception);
Notify.ShowMessageToast("程序出现一个错误,已记录");
}
catch (Exception)
@@ -70,7 +70,7 @@ private void App_UnhandledException(object sender, Windows.UI.Xaml.UnhandledExce
e.Handled = true;
try
{
- logger.Log("程序运行出现错误", LogType.ERROR, e.Exception);
+ logger.Log("程序运行出现错误", LogType.Error, e.Exception);
Notify.ShowMessageToast("程序出现一个错误,已记录");
}
catch (Exception)
diff --git a/src/BiliLite.UWP/Controls/Player.xaml.cs b/src/BiliLite.UWP/Controls/Player.xaml.cs
index 8b302f5f..ff178faa 100644
--- a/src/BiliLite.UWP/Controls/Player.xaml.cs
+++ b/src/BiliLite.UWP/Controls/Player.xaml.cs
@@ -1135,7 +1135,7 @@ public void Pause()
}
catch (Exception ex)
{
- _logger.Log("暂停出现错误", LogType.ERROR, ex);
+ _logger.Log("暂停出现错误", LogType.Error, ex);
}
}
diff --git a/src/BiliLite.UWP/Dialogs/LoginDialog.xaml.cs b/src/BiliLite.UWP/Dialogs/LoginDialog.xaml.cs
index 24faad52..096a59e3 100644
--- a/src/BiliLite.UWP/Dialogs/LoginDialog.xaml.cs
+++ b/src/BiliLite.UWP/Dialogs/LoginDialog.xaml.cs
@@ -133,7 +133,7 @@ private async void webView_NavigationStarting(WebView sender, WebViewNavigationS
}
catch (Exception ex)
{
- logger.Log("注入JS对象失败", LogType.ERROR, ex);
+ logger.Log("注入JS对象失败", LogType.Error, ex);
}
}
@@ -141,7 +141,7 @@ private async void WebView_NavigationCompleted(WebView sender, WebViewNavigation
{
if (args.Uri.AbsoluteUri == "https://passport.bilibili.com/ajax/miniLogin/redirect" || args.Uri.AbsoluteUri == "https://www.bilibili.com/")
{
- var results = await "https://passport.bilibili.com/login/app/third?appkey=27eb53fc9058f8c3&api=http%3A%2F%2Flink.acg.tv%2Fforum.php&sign=67ec798004373253d60114caaad89a8c".GetString();
+ var results = await $"https://passport.bilibili.com/login/app/third?appkey=&api=http%3A%2F%2Flink.acg.tv%2Fforum.php&sign=67ec798004373253d60114caaad89a8c".GetString();
var obj = JObject.Parse(results);
if (obj["code"].ToInt32() == 0)
{
diff --git a/src/BiliLite.UWP/Extensions/ApiModelExtensions.cs b/src/BiliLite.UWP/Extensions/ApiModelExtensions.cs
index 6dd9b09c..f1f4e24e 100644
--- a/src/BiliLite.UWP/Extensions/ApiModelExtensions.cs
+++ b/src/BiliLite.UWP/Extensions/ApiModelExtensions.cs
@@ -1,18 +1,23 @@
+using System.Runtime.CompilerServices;
using System.Threading.Tasks;
using BiliLite.Models.Requests;
using BiliLite.Models.Responses;
+using BiliLite.Services;
namespace BiliLite.Extensions
{
public static class ApiModelExtensions
{
+ private static readonly ILogger _logger = GlobalLogger.FromCurrentType();
+
///
/// չ
///
///
///
- public static async Task Request(this ApiModel api)
+ public static async Task Request(this ApiModel api, [CallerMemberName] string methodName = null)
{
+ _logger.Trace($"¼ {methodName} {api.baseUrl}");
if (api.method == RestSharp.Method.Get)
{
if (api.need_redirect)
diff --git a/src/BiliLite.UWP/Extensions/BiliExtensions.cs b/src/BiliLite.UWP/Extensions/BiliExtensions.cs
index 9b393e70..a2bd8a35 100644
--- a/src/BiliLite.UWP/Extensions/BiliExtensions.cs
+++ b/src/BiliLite.UWP/Extensions/BiliExtensions.cs
@@ -80,7 +80,7 @@ public static async Task CheckVersion()
try
{
var num = $"{SystemInformation.ApplicationVersion.Major}{SystemInformation.ApplicationVersion.Minor.ToString("00")}{SystemInformation.ApplicationVersion.Build.ToString("00")}";
- _logger.Info($"BiliLite.UWP version: {num}");
+ _logger.Log($"BiliLite.UWP version: {num}", LogType.Necessary);
var result = await new GitApi().CheckUpdate().Request();
var ver = JsonConvert.DeserializeObject(result.results);
var ignoreVersion = SettingService.GetValue(SettingConstants.Other.IGNORE_VERSION, "");
diff --git a/src/BiliLite.UWP/Extensions/StringHttpExtensions.cs b/src/BiliLite.UWP/Extensions/StringHttpExtensions.cs
index 953520af..7847b839 100644
--- a/src/BiliLite.UWP/Extensions/StringHttpExtensions.cs
+++ b/src/BiliLite.UWP/Extensions/StringHttpExtensions.cs
@@ -75,7 +75,7 @@ public static async Task GetRedirectHttpResultsWithWebCookie(this s
}
catch (Exception ex)
{
- logger.Log("GET请求失败" + url, LogType.ERROR, ex);
+ logger.Log("GET请求失败" + url, LogType.Error, ex);
return new HttpResults()
{
code = ex.HResult,
@@ -110,7 +110,7 @@ public static async Task GetHttpResultsWithWebCookie(this string ur
}
catch (Exception ex)
{
- logger.Log("GET请求失败" + url, LogType.ERROR, ex);
+ logger.Log("GET请求失败" + url, LogType.Error, ex);
return new HttpResults()
{
code = ex.HResult,
@@ -136,7 +136,7 @@ public static async Task GetStream(this string url, IDictionary GetBuffer(this string url, IDictionary GetString(this string url, IDictionary PostHttpResultsWithCookie(this string url,
}
catch (Exception ex)
{
- logger.Log("GET请求失败" + url, LogType.ERROR, ex);
+ logger.Log("GET请求失败" + url, LogType.Error, ex);
return new HttpResults()
{
code = ex.HResult,
diff --git a/src/BiliLite.UWP/Models/Common/Enumerates.cs b/src/BiliLite.UWP/Models/Common/Enumerates.cs
index 16a530ed..385f9268 100644
--- a/src/BiliLite.UWP/Models/Common/Enumerates.cs
+++ b/src/BiliLite.UWP/Models/Common/Enumerates.cs
@@ -2,10 +2,13 @@
{
public enum LogType
{
- INFO,
- DEBUG,
- ERROR,
- FATAL
+ Trace,
+ Debug,
+ Info,
+ Warn,
+ Error,
+ Fatal,
+ Necessary,
}
public enum LoginStatus
diff --git a/src/BiliLite.UWP/Models/Common/SettingConstants.cs b/src/BiliLite.UWP/Models/Common/SettingConstants.cs
index 762472b0..0f633d74 100644
--- a/src/BiliLite.UWP/Models/Common/SettingConstants.cs
+++ b/src/BiliLite.UWP/Models/Common/SettingConstants.cs
@@ -549,6 +549,11 @@ public class Other
///
public const string PROTECT_LOG_INFO = "protectLogInfo";
+ ///
+ /// 日志级别
+ ///
+ public const string LOG_LEVEL = "LogLevel";
+
///
/// 忽略版本
///
diff --git a/src/BiliLite.UWP/Models/Requests/Api/AccountApi.cs b/src/BiliLite.UWP/Models/Requests/Api/AccountApi.cs
index c8896648..cadcc059 100644
--- a/src/BiliLite.UWP/Models/Requests/Api/AccountApi.cs
+++ b/src/BiliLite.UWP/Models/Requests/Api/AccountApi.cs
@@ -112,9 +112,9 @@ public ApiModel SMSLogin(string cid, string phone, string code, string session_i
{
method = RestSharp.Method.Post,
baseUrl = "https://passport.bilibili.com/x/passport-login/login/sms",
- body = $"actionKey=appkey&cid={cid}&tel={phone}&login_session_id={session_id}&captcha_key={captcha_key}&code={code}&" + ApiHelper.MustParameter(ApiHelper.LoginKey)
+ body = $"actionKey=appkey&cid={cid}&tel={phone}&login_session_id={session_id}&captcha_key={captcha_key}&code={code}&" + ApiHelper.MustParameter(ApiHelper.AndroidKey)
};
- api.body += ApiHelper.GetSign(api.body, ApiHelper.LoginKey);
+ api.body += ApiHelper.GetSign(api.body, ApiHelper.AndroidKey);
return api;
}
///
diff --git a/src/BiliLite.UWP/Models/Requests/Api/User/UserDetailAPI.cs b/src/BiliLite.UWP/Models/Requests/Api/User/UserDetailAPI.cs
index b40c3276..0472cbcd 100644
--- a/src/BiliLite.UWP/Models/Requests/Api/User/UserDetailAPI.cs
+++ b/src/BiliLite.UWP/Models/Requests/Api/User/UserDetailAPI.cs
@@ -162,6 +162,7 @@ public ApiModel Followers(string mid, int page = 1, int pagesize = 30)
method = RestSharp.Method.Get,
baseUrl = $"{ApiHelper.API_BASE_URL}/x/relation/followers",
parameter = $"vmid={mid}&ps={pagesize}&pn={page}&order=desc",
+ need_cookie = true,
};
return api;
}
diff --git a/src/BiliLite.UWP/Models/Requests/BiliRequest.cs b/src/BiliLite.UWP/Models/Requests/BiliRequest.cs
index fc653322..4df32258 100644
--- a/src/BiliLite.UWP/Models/Requests/BiliRequest.cs
+++ b/src/BiliLite.UWP/Models/Requests/BiliRequest.cs
@@ -150,7 +150,7 @@ private async Task LogRequest()
var body = "";
if (m_body != null)
body = await m_body?.ReadAsStringAsync();
- logger.Log($"网络请求: [{m_method}]{m_url} {body}", LogType.INFO);
+ logger.Log($"网络请求: [{m_method}]{m_url} {body}", LogType.Info);
}
public async Task Send()
@@ -185,7 +185,7 @@ public async Task Send()
}
catch (Exception ex)
{
- logger.Log($"{m_method.Method}请求失败" + m_url, LogType.ERROR, ex);
+ logger.Log($"{m_method.Method}请求失败" + m_url, LogType.Error, ex);
httpResults = await ConstructExResults(ex);
}
diff --git a/src/BiliLite.UWP/Modules/Detail/LiveRoomVM.cs b/src/BiliLite.UWP/Modules/Detail/LiveRoomVM.cs
index 34134e79..2bce21de 100644
--- a/src/BiliLite.UWP/Modules/Detail/LiveRoomVM.cs
+++ b/src/BiliLite.UWP/Modules/Detail/LiveRoomVM.cs
@@ -434,7 +434,7 @@ public async Task GetTitles()
}
catch (Exception ex)
{
- _logger.Log("读取直播头衔失败", LogType.FATAL, ex);
+ _logger.Log("读取直播头衔失败", LogType.Fatal, ex);
}
}
///
@@ -866,7 +866,7 @@ public async Task GetRoomGiftList()
catch (Exception ex)
{
Notify.ShowMessageToast("读取礼物信息失败");
- _logger.Log("读取礼物信息失败", LogType.ERROR, ex);
+ _logger.Log("读取礼物信息失败", LogType.Error, ex);
}
}
@@ -933,7 +933,7 @@ public async Task GetGuardList()
catch (Exception ex)
{
Notify.ShowMessageToast("读取舰队失败");
- _logger.Log("读取舰队失败", LogType.ERROR, ex);
+ _logger.Log("读取舰队失败", LogType.Error, ex);
}
finally
{
@@ -1003,7 +1003,7 @@ public async Task GetFreeSilverTime()
catch (Exception ex)
{
Notify.ShowMessageToast("读取直播免费瓜子时间失败");
- _logger.Log("读取直播免费瓜子时间失败", LogType.ERROR, ex);
+ _logger.Log("读取直播免费瓜子时间失败", LogType.Error, ex);
}
}
@@ -1034,7 +1034,7 @@ public async Task GetFreeSilver()
catch (Exception ex)
{
Notify.ShowMessageToast("读取直播免费瓜子时间失败");
- _logger.Log("读取直播免费瓜子时间失败", LogType.ERROR, ex);
+ _logger.Log("读取直播免费瓜子时间失败", LogType.Error, ex);
}
}
@@ -1088,7 +1088,7 @@ public async Task SendGift(LiveGiftItem liveGiftItem)
}
catch (Exception ex)
{
- _logger.Log("赠送礼物出现错误", LogType.ERROR, ex);
+ _logger.Log("赠送礼物出现错误", LogType.Error, ex);
Notify.ShowMessageToast("赠送礼物出现错误");
}
@@ -1122,7 +1122,7 @@ public async Task SendBagGift(LiveGiftItem liveGiftItem)
}
catch (Exception ex)
{
- _logger.Log("赠送礼物出现错误", LogType.ERROR, ex);
+ _logger.Log("赠送礼物出现错误", LogType.Error, ex);
Notify.ShowMessageToast("赠送礼物出现错误");
}
@@ -1177,7 +1177,7 @@ public async Task SendDanmu(string text)
}
catch (Exception ex)
{
- _logger.Log("发送弹幕出现错误", LogType.ERROR, ex);
+ _logger.Log("发送弹幕出现错误", LogType.Error, ex);
Notify.ShowMessageToast("发送弹幕出现错误");
return false;
}
@@ -1323,7 +1323,7 @@ public async Task LoadData()
catch (Exception ex)
{
Notify.ShowMessageToast("读取直播排行榜失败:" + RankType);
- logger.Log("读取直播排行榜失败" + RankType, LogType.ERROR, ex);
+ logger.Log("读取直播排行榜失败" + RankType, LogType.Error, ex);
}
finally
{
@@ -1431,7 +1431,7 @@ public async Task LoadLotteryInfo(int roomId)
}
catch (Exception ex)
{
- logger.Log("加载主播抽奖信息失败", LogType.ERROR, ex);
+ logger.Log("加载主播抽奖信息失败", LogType.Error, ex);
}
}
diff --git a/src/BiliLite.UWP/Modules/IModules.cs b/src/BiliLite.UWP/Modules/IModules.cs
index ca342bc7..0b842607 100644
--- a/src/BiliLite.UWP/Modules/IModules.cs
+++ b/src/BiliLite.UWP/Modules/IModules.cs
@@ -26,7 +26,7 @@ public virtual ReturnModel HandelError(Exception ex, [CallerMemberName] st
else
{
var type = new StackTrace().GetFrame(1).GetMethod().ReflectedType;
- _logger.Log(ex.Message, LogType.ERROR, ex, methodName, type.Name);
+ _logger.Log(ex.Message, LogType.Error, ex, methodName, type.Name);
return new ReturnModel()
{
success = false,
diff --git a/src/BiliLite.UWP/Modules/Live/LiveCenter/LiveCenterVM.cs b/src/BiliLite.UWP/Modules/Live/LiveCenter/LiveCenterVM.cs
index edb27309..e59668a1 100644
--- a/src/BiliLite.UWP/Modules/Live/LiveCenter/LiveCenterVM.cs
+++ b/src/BiliLite.UWP/Modules/Live/LiveCenter/LiveCenterVM.cs
@@ -57,7 +57,7 @@ public async void GetUserInfo()
}
catch (Exception ex)
{
- logger.Log("读取签到信息失败", LogType.ERROR, ex);
+ logger.Log("读取签到信息失败", LogType.Error, ex);
Notify.ShowMessageToast("读取签到信息失败");
}
}
diff --git a/src/BiliLite.UWP/Modules/Live/LiveDanmaku.cs b/src/BiliLite.UWP/Modules/Live/LiveDanmaku.cs
index 70aca4df..d2e6bb8e 100644
--- a/src/BiliLite.UWP/Modules/Live/LiveDanmaku.cs
+++ b/src/BiliLite.UWP/Modules/Live/LiveDanmaku.cs
@@ -331,7 +331,7 @@ private async void Listen()
}
catch (Exception ex)
{
- logger.Log("加载直播弹幕失败", LogType.ERROR, ex);
+ logger.Log("加载直播弹幕失败", LogType.Error, ex);
}
await Task.Delay(delay);
diff --git a/src/BiliLite.UWP/Modules/Live/LiveMessage.cs b/src/BiliLite.UWP/Modules/Live/LiveMessage.cs
index 39d653e9..ac408f9a 100644
--- a/src/BiliLite.UWP/Modules/Live/LiveMessage.cs
+++ b/src/BiliLite.UWP/Modules/Live/LiveMessage.cs
@@ -118,7 +118,7 @@ public async Task Connect(int roomID, int uid, CancellationToken cancellationTok
{
return;
}
- logger.Log("直播接收包出错", LogType.ERROR, ex);
+ logger.Log("直播接收包出错", LogType.Error, ex);
}
}
}
diff --git a/src/BiliLite.UWP/Modules/Live/LiveRecommendVM.cs b/src/BiliLite.UWP/Modules/Live/LiveRecommendVM.cs
index 1565a47e..6d183ea5 100644
--- a/src/BiliLite.UWP/Modules/Live/LiveRecommendVM.cs
+++ b/src/BiliLite.UWP/Modules/Live/LiveRecommendVM.cs
@@ -186,7 +186,7 @@ public async Task> GetRecommend(int page)
}
catch (Exception ex)
{
- logger.Log("加载直播推荐信息失败", LogType.ERROR, ex);
+ logger.Log("加载直播推荐信息失败", LogType.Error, ex);
Notify.ShowMessageToast("加载直播推荐信息失败");
return new List();
}
diff --git a/src/BiliLite.UWP/Modules/Player/PlayerVM.cs b/src/BiliLite.UWP/Modules/Player/PlayerVM.cs
index b7231e40..77c4ead1 100644
--- a/src/BiliLite.UWP/Modules/Player/PlayerVM.cs
+++ b/src/BiliLite.UWP/Modules/Player/PlayerVM.cs
@@ -168,7 +168,7 @@ public async Task GetSubtitle(string url)
catch (Exception ex)
{
Notify.ShowMessageToast("弹幕加载失败:" + ex.Message);
- logger.Log("grpc弹幕加载失败", LogType.FATAL, ex);
+ logger.Log("grpc弹幕加载失败", LogType.Fatal, ex);
}
return danmuList;
}
diff --git a/src/BiliLite.UWP/Modules/SettingVM.cs b/src/BiliLite.UWP/Modules/SettingVM.cs
index 706222be..7f74facc 100644
--- a/src/BiliLite.UWP/Modules/SettingVM.cs
+++ b/src/BiliLite.UWP/Modules/SettingVM.cs
@@ -155,7 +155,7 @@ public async Task SyncDanmuFilter()
}
catch (Exception ex)
{
- logger.Log("读取弹幕屏蔽词失败", LogType.ERROR, ex);
+ logger.Log("读取弹幕屏蔽词失败", LogType.Error, ex);
}
}
@@ -173,7 +173,7 @@ public async Task AddDanmuFilterItem(string word, int type)
}
catch (Exception ex)
{
- logger.Log("添加弹幕屏蔽词失败", LogType.ERROR, ex);
+ logger.Log("添加弹幕屏蔽词失败", LogType.Error, ex);
return false;
}
}
diff --git a/src/BiliLite.UWP/Modules/User/Account.cs b/src/BiliLite.UWP/Modules/User/Account.cs
index 30e5489a..3bd5f07a 100644
--- a/src/BiliLite.UWP/Modules/User/Account.cs
+++ b/src/BiliLite.UWP/Modules/User/Account.cs
@@ -104,18 +104,15 @@ public async Task SaveLogin(string access_key, string refresh_token, int e
if (cookie != null)
{
var cookies = new List();
- foreach (var domainItem in cookie.domains)
+ cookies.AddRange(cookie.cookies.Select(cookieItem => new HttpCookieItem()
{
- cookies.AddRange(cookie.cookies.Select(cookieItem => new HttpCookieItem()
- {
- Domain = domainItem,
- Expires = TimeExtensions.TimestampToDatetime(cookieItem.expires),
- HttpOnly = cookieItem.http_only == 1,
- Name = cookieItem.name,
- Secure = cookieItem.secure == 1,
- Value = cookieItem.value,
- }));
- }
+ Domain = Constants.BILIBILI_DOMAIN,
+ Expires = TimeExtensions.TimestampToDatetime(cookieItem.expires),
+ HttpOnly = cookieItem.http_only == 1,
+ Name = cookieItem.name,
+ Secure = cookieItem.secure == 1,
+ Value = cookieItem.value,
+ }));
m_cookieService.Cookies = cookies;
}
//执行SSO
@@ -123,7 +120,7 @@ public async Task SaveLogin(string access_key, string refresh_token, int e
}
catch (Exception ex)
{
- _logger.Log($"SSO失败", LogType.ERROR, ex);
+ _logger.Log($"SSO失败", LogType.Error, ex);
}
//读取个人资料
@@ -134,7 +131,7 @@ public async Task SaveLogin(string access_key, string refresh_token, int e
}
catch (Exception ex)
{
- _logger.Log("安全验证后设置保存信息失败", LogType.ERROR, ex);
+ _logger.Log("安全验证后设置保存信息失败", LogType.Error, ex);
return false;
}
}
@@ -158,7 +155,7 @@ public async Task GetProfile()
}
catch (Exception ex)
{
- _logger.Log("读取个人资料失败", LogType.ERROR, ex);
+ _logger.Log("读取个人资料失败", LogType.Error, ex);
return null;
}
}
diff --git a/src/BiliLite.UWP/Modules/User/LoginVM.cs b/src/BiliLite.UWP/Modules/User/LoginVM.cs
index 46b2848e..acb32192 100644
--- a/src/BiliLite.UWP/Modules/User/LoginVM.cs
+++ b/src/BiliLite.UWP/Modules/User/LoginVM.cs
@@ -161,7 +161,7 @@ public async void ValidateLogin(JObject jObject)
}
catch (Exception ex)
{
- logger.Log("登录二次验证失败", LogType.ERROR, ex);
+ logger.Log("登录二次验证失败", LogType.Error, ex);
}
}
@@ -612,7 +612,7 @@ private async void GetQRAuthInfo()
}
catch (Exception ex)
{
- logger.Log("读取和加载登录二维码失败", LogType.ERROR, ex);
+ logger.Log("读取和加载登录二维码失败", LogType.Error, ex);
Notify.ShowMessageToast("加载二维码失败");
}
finally
@@ -710,7 +710,7 @@ private async void FetchHideTelNumber()
}
catch (Exception ex)
{
- logger.Log("获取验证手机号失败", LogType.ERROR, ex);
+ logger.Log("获取验证手机号失败", LogType.Error, ex);
}
}
@@ -743,7 +743,7 @@ private async void SendPwdLoginVerifySMS()
}
catch (Exception ex)
{
- logger.Log("发送短信验证码失败", LogType.ERROR, ex);
+ logger.Log("发送短信验证码失败", LogType.Error, ex);
}
}
@@ -844,7 +844,7 @@ private async Task StartGeetestCaptcha()
}
catch (Exception ex)
{
- logger.Log("读取极验验证码失败", LogType.ERROR, ex);
+ logger.Log("读取极验验证码失败", LogType.Error, ex);
return null;
}
}
diff --git a/src/BiliLite.UWP/Modules/User/SendDynamic/SendDynamicVM.cs b/src/BiliLite.UWP/Modules/User/SendDynamic/SendDynamicVM.cs
index 574e18f2..3e2d4ab8 100644
--- a/src/BiliLite.UWP/Modules/User/SendDynamic/SendDynamicVM.cs
+++ b/src/BiliLite.UWP/Modules/User/SendDynamic/SendDynamicVM.cs
@@ -110,7 +110,7 @@ public async void UploadImage(StorageFile file)
}
catch (Exception ex)
{
- logger.Log("图片上传失败", LogType.FATAL, ex);
+ logger.Log("图片上传失败", LogType.Fatal, ex);
Notify.ShowMessageToast("图片上传失败");
}
finally
@@ -189,7 +189,7 @@ public async Task SendRepost()
catch (Exception ex)
{
Notify.ShowMessageToast("转发动态失败" + ex.Message);
- logger.Log("转发动态失败", LogType.ERROR, ex);
+ logger.Log("转发动态失败", LogType.Error, ex);
return false;
}
@@ -280,7 +280,7 @@ public async Task SendDynamic()
{
Notify.ShowMessageToast("发表动态发生错误");
- logger.Log("发表动态失败", LogType.ERROR, ex);
+ logger.Log("发表动态失败", LogType.Error, ex);
return false;
}
diff --git a/src/BiliLite.UWP/Modules/User/UserDetail/UserDetailVM.cs b/src/BiliLite.UWP/Modules/User/UserDetail/UserDetailVM.cs
index eacf6ce5..aa177882 100644
--- a/src/BiliLite.UWP/Modules/User/UserDetail/UserDetailVM.cs
+++ b/src/BiliLite.UWP/Modules/User/UserDetail/UserDetailVM.cs
@@ -68,7 +68,7 @@ public async void GetUserInfo()
}
catch (Exception ex)
{
- logger.Log("读取个人资料失败", LogType.ERROR, ex);
+ logger.Log("读取个人资料失败", LogType.Error, ex);
Notify.ShowMessageToast("读取个人资料失败");
}
}
@@ -98,7 +98,7 @@ public async Task GetStat()
}
catch (Exception ex)
{
- logger.Log("读取个人资料失败", LogType.ERROR, ex);
+ logger.Log("读取个人资料失败", LogType.Error, ex);
return null;
}
}
@@ -135,7 +135,7 @@ public async Task GetSpeceStat()
}
catch (Exception ex)
{
- logger.Log("读取个人资料失败", LogType.ERROR, ex);
+ logger.Log("读取个人资料失败", LogType.Error, ex);
return null;
}
}
diff --git a/src/BiliLite.UWP/Pages/DownloadPage.xaml.cs b/src/BiliLite.UWP/Pages/DownloadPage.xaml.cs
index 27254581..318c4060 100644
--- a/src/BiliLite.UWP/Pages/DownloadPage.xaml.cs
+++ b/src/BiliLite.UWP/Pages/DownloadPage.xaml.cs
@@ -177,7 +177,7 @@ private async void btnEpisodesDelete_Click(object sender, RoutedEventArgs e)
catch (Exception ex)
{
Notify.ShowMessageToast("目录删除失败,请检查是否文件是否被占用");
- logger.Log("删除下载视频失败", LogType.FATAL, ex);
+ logger.Log("删除下载视频失败", LogType.Fatal, ex);
}
}
@@ -236,7 +236,7 @@ private async void btnMenuDetele_Click(object sender, RoutedEventArgs e)
catch (Exception ex)
{
Notify.ShowMessageToast("目录删除失败,请检查是否文件是否被占用");
- logger.Log("删除下载视频失败", LogType.FATAL, ex);
+ logger.Log("删除下载视频失败", LogType.Fatal, ex);
}
@@ -295,7 +295,7 @@ private async void OutputFile(DownloadedItem data, DownloadedSubItem item)
catch (Exception ex)
{
Notify.ShowMessageToast("转换SRT字幕失败");
- logger.Log("转换字幕失败", LogType.ERROR, ex);
+ logger.Log("转换字幕失败", LogType.Error, ex);
}
}
diff --git a/src/BiliLite.UWP/Pages/HomePage.xaml.cs b/src/BiliLite.UWP/Pages/HomePage.xaml.cs
index 55120981..88d7ce6d 100644
--- a/src/BiliLite.UWP/Pages/HomePage.xaml.cs
+++ b/src/BiliLite.UWP/Pages/HomePage.xaml.cs
@@ -82,7 +82,7 @@ private async void CheckLoginStatus()
catch (Exception ex)
{
homeVM.IsLogin = false;
- logger.Log("读取access_key信息失败", LogType.INFO, ex);
+ logger.Log("读取access_key信息失败", LogType.Info, ex);
Notify.ShowMessageToast("读取登录信息失败,请重新登录");
//throw;
}
diff --git a/src/BiliLite.UWP/Pages/LiveDetailPage.xaml.cs b/src/BiliLite.UWP/Pages/LiveDetailPage.xaml.cs
index 3a3b64d7..d9485ebc 100644
--- a/src/BiliLite.UWP/Pages/LiveDetailPage.xaml.cs
+++ b/src/BiliLite.UWP/Pages/LiveDetailPage.xaml.cs
@@ -144,7 +144,7 @@ private void LiveRoomVM_AddNewDanmu(object sender, string e)
catch (Exception ex)
{
//记录错误,不弹出通知
- logger.Log(ex.Message, LogType.ERROR, ex);
+ logger.Log(ex.Message, LogType.Error, ex);
}
}
@@ -191,7 +191,7 @@ private async void MediaPlayer_MediaFailed(MediaPlayer sender, MediaPlayerFailed
{
await this.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, async () =>
{
- logger.Log("直播加载失败", LogType.ERROR, new Exception(args.ErrorMessage));
+ logger.Log("直播加载失败", LogType.Error, new Exception(args.ErrorMessage));
await new MessageDialog($"啊,直播加载失败了\r\n错误信息:{args.ErrorMessage}\r\n请尝试在直播设置中打开/关闭硬解试试", "播放失败").ShowAsync();
});
diff --git a/src/BiliLite.UWP/Pages/SeasonDetailPage.xaml.cs b/src/BiliLite.UWP/Pages/SeasonDetailPage.xaml.cs
index 8d1a243a..0f636126 100644
--- a/src/BiliLite.UWP/Pages/SeasonDetailPage.xaml.cs
+++ b/src/BiliLite.UWP/Pages/SeasonDetailPage.xaml.cs
@@ -388,7 +388,7 @@ private void CreateQR()
}
catch (Exception ex)
{
- logger.Log("创建二维码失败epid" + ep_id, LogType.ERROR, ex);
+ logger.Log("创建二维码失败epid" + ep_id, LogType.Error, ex);
Notify.ShowMessageToast("创建二维码失败");
}
diff --git a/src/BiliLite.UWP/Pages/SettingPage.xaml b/src/BiliLite.UWP/Pages/SettingPage.xaml
index b02e797c..2e4cfc4a 100644
--- a/src/BiliLite.UWP/Pages/SettingPage.xaml
+++ b/src/BiliLite.UWP/Pages/SettingPage.xaml
@@ -566,6 +566,17 @@
保护日志中敏感信息
+ 日志级别
+
+
+ Trace
+ Debug
+ Info
+ Warn
+ Error
+ Fatal
+
+
BiliLite-WebApi(用于处理UWP无法完成的事项)
diff --git a/src/BiliLite.UWP/Pages/SettingPage.xaml.cs b/src/BiliLite.UWP/Pages/SettingPage.xaml.cs
index 7feba976..16a140a7 100644
--- a/src/BiliLite.UWP/Pages/SettingPage.xaml.cs
+++ b/src/BiliLite.UWP/Pages/SettingPage.xaml.cs
@@ -735,6 +735,15 @@ private void LoadOther()
{
SettingService.SetValue(SettingConstants.Other.PROTECT_LOG_INFO, swProtectLogInfo.IsOn);
});
+ // 日志级别
+ cbLogLevel.SelectedIndex = SettingService.GetValue(SettingConstants.Other.LOG_LEVEL, 2);
+ cbLogLevel.Loaded += (sender, e) =>
+ {
+ cbLogLevel.SelectionChanged += (obj, args) =>
+ {
+ SettingService.SetValue(SettingConstants.Other.LOG_LEVEL, cbLogLevel.SelectedIndex);
+ };
+ };
// BiliLiteWebApi
BiliLiteWebApiTextBox.Text = SettingService.GetValue(SettingConstants.Other.BILI_LITE_WEB_API_BASE_URL, ApiConstants.BILI_LITE_WEB_API_DEFAULT_BASE_URL);
BiliLiteWebApiTextBox.Loaded += (sender, e) =>
diff --git a/src/BiliLite.UWP/Pages/VideoDetailPage.xaml.cs b/src/BiliLite.UWP/Pages/VideoDetailPage.xaml.cs
index 9c0d0601..9c0fe2bd 100644
--- a/src/BiliLite.UWP/Pages/VideoDetailPage.xaml.cs
+++ b/src/BiliLite.UWP/Pages/VideoDetailPage.xaml.cs
@@ -288,7 +288,7 @@ private void CreateQR()
}
catch (Exception ex)
{
- logger.Log("创建二维码失败avid" + avid, LogType.ERROR, ex);
+ logger.Log("创建二维码失败avid" + avid, LogType.Error, ex);
Notify.ShowMessageToast("创建二维码失败");
}
diff --git a/src/BiliLite.UWP/Services/AppHelper.cs b/src/BiliLite.UWP/Services/AppHelper.cs
index c903a554..300bdaea 100644
--- a/src/BiliLite.UWP/Services/AppHelper.cs
+++ b/src/BiliLite.UWP/Services/AppHelper.cs
@@ -27,7 +27,7 @@ public static class AppHelper
}
catch (Exception ex)
{
- logger.Log("读取默认分区失败!" + ex.Message, LogType.ERROR, ex);
+ logger.Log("读取默认分区失败!" + ex.Message, LogType.Error, ex);
return new List();
}
}
@@ -69,7 +69,7 @@ public static async Task SetRegions()
catch (Exception ex)
{
Regions = await AppHelper.GetDefaultRegions();
- logger.Log("读取分区失败" + ex.Message, LogType.ERROR, ex);
+ logger.Log("读取分区失败" + ex.Message, LogType.Error, ex);
}
}
diff --git a/src/BiliLite.UWP/Services/DownloadHelper.cs b/src/BiliLite.UWP/Services/DownloadHelper.cs
index 6b500d19..71630c23 100644
--- a/src/BiliLite.UWP/Services/DownloadHelper.cs
+++ b/src/BiliLite.UWP/Services/DownloadHelper.cs
@@ -68,7 +68,7 @@ private static async Task DownloadCover(string url, StorageFolder folder)
}
catch (Exception ex)
{
- logger.Log("封面下载失败:" + url, LogType.ERROR, ex);
+ logger.Log("封面下载失败:" + url, LogType.Error, ex);
}
}
private static async Task DownloadDanmaku(string url, StorageFolder episodeFolder)
@@ -83,7 +83,7 @@ private static async Task DownloadDanmaku(string url, StorageFolder episodeFolde
}
catch (Exception ex)
{
- logger.Log("弹幕下载失败:" + url, LogType.ERROR, ex);
+ logger.Log("弹幕下载失败:" + url, LogType.Error, ex);
}
}
private static async Task SaveInfo(DownloadInfo info, StorageFolder folder, StorageFolder episodeFolder)
@@ -135,7 +135,7 @@ private static async Task SaveInfo(DownloadInfo info, StorageFolder folder, Stor
}
catch (Exception ex)
{
- logger.Log("文件保存失败:" + episodeFolder.Path, LogType.ERROR, ex);
+ logger.Log("文件保存失败:" + episodeFolder.Path, LogType.Error, ex);
}
}
private static async Task DownloadSubtitle(DownloadSubtitleInfo subtitleInfo, StorageFolder episodeFolder)
@@ -155,7 +155,7 @@ private static async Task DownloadSubtitle(DownloadSubtitleInfo subtitleInfo, St
}
catch (Exception ex)
{
- logger.Log($"字幕下载失败:{subtitleInfo.Name}={subtitleInfo.Url}", LogType.ERROR, ex);
+ logger.Log($"字幕下载失败:{subtitleInfo.Name}={subtitleInfo.Url}", LogType.Error, ex);
}
}
private static async void DownloadVideo(DownloadInfo downloadInfo, DownloadUrlInfo url, StorageFolder episodeFolder)
diff --git a/src/BiliLite.UWP/Services/GlobalLogger.cs b/src/BiliLite.UWP/Services/GlobalLogger.cs
index bf94c3e8..bf2657af 100644
--- a/src/BiliLite.UWP/Services/GlobalLogger.cs
+++ b/src/BiliLite.UWP/Services/GlobalLogger.cs
@@ -9,24 +9,29 @@ public class GlobalLogger : ILogger
{
private string m_typeName;
+ public void Trace(string message, Exception ex = null, string methodName = null)
+ {
+ LogService.Log(message, LogType.Trace, ex, methodName, m_typeName);
+ }
+
public void Info(string message, Exception ex = null, [CallerMemberName] string methodName = null)
{
- LogService.Log(message, LogType.INFO, ex, methodName, m_typeName);
+ LogService.Log(message, LogType.Info, ex, methodName, m_typeName);
}
public void Debug(string message, Exception ex = null, [CallerMemberName] string methodName = null)
{
- LogService.Log(message, LogType.DEBUG, ex, methodName, m_typeName);
+ LogService.Log(message, LogType.Debug, ex, methodName, m_typeName);
}
public void Error(string message, Exception ex = null, [CallerMemberName] string methodName = null)
{
- LogService.Log(message, LogType.ERROR, ex, methodName, m_typeName);
+ LogService.Log(message, LogType.Error, ex, methodName, m_typeName);
}
public void Fatal(string message, Exception ex = null, [CallerMemberName] string methodName = null)
{
- LogService.Log(message, LogType.FATAL, ex, methodName, m_typeName);
+ LogService.Log(message, LogType.Fatal, ex, methodName, m_typeName);
}
public void Log(string message, LogType type, Exception ex = null, [CallerMemberName] string methodName = null, string typeName = null)
diff --git a/src/BiliLite.UWP/Services/ILogger.cs b/src/BiliLite.UWP/Services/ILogger.cs
index 4c9bcfaa..5d17dc2e 100644
--- a/src/BiliLite.UWP/Services/ILogger.cs
+++ b/src/BiliLite.UWP/Services/ILogger.cs
@@ -6,6 +6,8 @@ namespace BiliLite.Services
{
public interface ILogger
{
+ public void Trace(string message, Exception ex = null, [CallerMemberName] string methodName = null);
+
public void Info(string message, Exception ex = null, [CallerMemberName] string methodName = null);
public void Debug(string message, Exception ex = null, [CallerMemberName] string methodName = null);
diff --git a/src/BiliLite.UWP/Services/LogService.cs b/src/BiliLite.UWP/Services/LogService.cs
index bfa13094..554f0bfe 100644
--- a/src/BiliLite.UWP/Services/LogService.cs
+++ b/src/BiliLite.UWP/Services/LogService.cs
@@ -24,6 +24,8 @@ public class LogService
private static int AutoClearLogFileDay => SettingService.GetValue(SettingConstants.Other.AUTO_CLEAR_LOG_FILE_DAY, 7);
private static bool IsProtectLogInfo => SettingService.GetValue(SettingConstants.Other.PROTECT_LOG_INFO, true);
+ private static int LogLowestLevel => SettingService.GetValue(SettingConstants.Other.LOG_LEVEL, 1);
+
public static ILoggerFactory Factory
{
get
@@ -86,27 +88,38 @@ private static async Task DeleteFile(string path)
public static void Log(string message, LogType type, Exception ex = null, [CallerMemberName] string methodName = null, string typeName = "unknowType")
{
- Debug.WriteLine("[" + LogType.INFO.ToString() + "]" + message);
+ Debug.WriteLine("[" + LogType.Info.ToString() + "]" + message);
+ if ((int)type < LogLowestLevel) return;
if (IsProtectLogInfo)
message = message.ProtectValues("access_key", "csrf", "access_token", "sign");
-
+
var logEvent = new LogEventInfo(LogLevel.Info, null, message);
switch (type)
{
- case LogType.INFO:
- logEvent.Level = LogLevel.Info;
+ case LogType.Trace:
+ logEvent.Level = LogLevel.Trace;
break;
- case LogType.DEBUG:
+ case LogType.Debug:
logEvent.Level = LogLevel.Debug;
break;
- case LogType.ERROR:
+ case LogType.Info:
+ logEvent.Level = LogLevel.Info;
+ break;
+ case LogType.Warn:
+ logEvent.Level = LogLevel.Warn;
+ logEvent.Exception = ex;
+ break;
+ case LogType.Error:
logEvent.Level = LogLevel.Error;
logEvent.Exception = ex;
break;
- case LogType.FATAL:
+ case LogType.Fatal:
logEvent.Level = LogLevel.Fatal;
logEvent.Exception = ex;
break;
+ case LogType.Necessary:
+ logEvent.Level = LogLevel.Info;
+ break;
default:
break;
}
diff --git a/src/BiliLite.UWP/Services/MessageCenter.cs b/src/BiliLite.UWP/Services/MessageCenter.cs
index d563e35e..57a3e106 100644
--- a/src/BiliLite.UWP/Services/MessageCenter.cs
+++ b/src/BiliLite.UWP/Services/MessageCenter.cs
@@ -84,7 +84,7 @@ private static void ClaerCookie()
}
catch (Exception ex)
{
- _logger.Log("清除用户Cookie", LogType.ERROR, ex);
+ _logger.Log("清除用户Cookie", LogType.Error, ex);
}
}
@@ -92,8 +92,9 @@ private static void ClaerCookie()
///统一处理Url
///
///
- public async static Task HandelUrl(string url, bool dontGoTo = false)
+ public static async Task HandelUrl(string url, bool dontGoTo = false)
{
+ _logger.Debug($"处理链接:{url}");
if (url.First() == '@')
{
return false;
@@ -114,7 +115,9 @@ public async static Task HandelUrl(string url, bool dontGoTo = false)
* bilibili://story/722919541
*/
- var video = StringExtensions.RegexMatch(url.Replace("aid", "av").Replace("/", "").Replace("=", ""), @"av(\d+)");
+ var video = "";
+
+ video = StringExtensions.RegexMatch(url, @"bilibili://video/(\d+)");
if (video != "")
{
NavigateToPage(null, new NavigationInfo()
@@ -127,7 +130,7 @@ public async static Task HandelUrl(string url, bool dontGoTo = false)
});
return true;
}
- video = StringExtensions.RegexMatch(url, @"bilibili://video/(\d+)");
+ video = StringExtensions.RegexMatch(url, @"bilibili://story/(\d+)");
if (video != "")
{
NavigateToPage(null, new NavigationInfo()
@@ -140,7 +143,8 @@ public async static Task HandelUrl(string url, bool dontGoTo = false)
});
return true;
}
- video = StringExtensions.RegexMatch(url, @"bilibili://story/(\d+)");
+
+ video = StringExtensions.RegexMatch(url.Replace("aid", "av").Replace("/", "").Replace("=", ""), @"av(\d+)");
if (video != "")
{
NavigateToPage(null, new NavigationInfo()
@@ -153,6 +157,7 @@ public async static Task HandelUrl(string url, bool dontGoTo = false)
});
return true;
}
+
video = StringExtensions.RegexMatch(url, @"avid=(\d+)");
if (video != "")
{
diff --git a/src/BiliLite.UWP/ViewModels/Common/BaseViewModel.cs b/src/BiliLite.UWP/ViewModels/Common/BaseViewModel.cs
index 35220047..22bccb6e 100644
--- a/src/BiliLite.UWP/ViewModels/Common/BaseViewModel.cs
+++ b/src/BiliLite.UWP/ViewModels/Common/BaseViewModel.cs
@@ -64,7 +64,7 @@ public virtual ReturnModel HandelError(Exception ex, [CallerMemberName] st
else
{
var type = new StackTrace().GetFrame(1).GetMethod().ReflectedType;
- _logger.Log(ex.Message, LogType.ERROR, ex, methodName, type.Name);
+ _logger.Log(ex.Message, LogType.Error, ex, methodName, type.Name);
return new ReturnModel()
{
success = false,