Commit cc1c4d07 authored by Sylvain Berfini's avatar Sylvain Berfini

Fix email reports if logs too big + delete linphone logs when file is very big

parent 60e93c5d
using Microsoft.Phone.Tasks;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.IO.IsolatedStorage;
using System.Linq;
......@@ -105,13 +106,9 @@ namespace Linphone.Model
if (store.FileExists(logFileName))
{
body += "\r\n";
// Limit the amount of linphone logs to the last 50ko
// Limit the amount of linphone logs
string logs = await ReadLogs();
if (logs.Length > 50000)
{
logs = logs.Substring(logs.Length - 50000);
}
body += logs;
body += logs.Length > 32000 ? logs.Substring(logs.Length - 32000) : logs;
}
}
EmailComposeTask email = new EmailComposeTask();
......@@ -153,6 +150,33 @@ namespace Linphone.Model
catch (Exception) { }
}
internal static void DeleteLinphoneLogFileIfFileTooBig()
{
bool delete = false;
try
{
using (var store = IsolatedStorageFile.GetUserStoreForApplication())
{
if (store.FileExists(logFileName))
{
using (var file = store.OpenFile(logFileName, FileMode.Open))
{
Debug.WriteLine("[BugCollector] Log file size is " + file.Length);
if (file.Length > 200000)
{
delete = true;
}
}
if (delete)
{
store.DeleteFile(logFileName);
}
}
}
}
catch (Exception) { }
}
internal static void DeleteLinphoneLogFile()
{
try
......
......@@ -3,6 +3,7 @@ using Linphone.Resources;
using Microsoft.Phone.Shell;
using Microsoft.Phone.Tasks;
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Threading.Tasks;
......@@ -16,6 +17,7 @@ namespace Linphone.Views
/// </summary>
public partial class Console : BasePage
{
private string logs;
/// <summary>
/// Public constructor
/// </summary>
......@@ -28,7 +30,7 @@ namespace Linphone.Views
private async void Browser_LoadCompleted(object sender, NavigationEventArgs e)
{
string logs = await ReadLogs();
logs = await ReadLogs();
FormatAndDisplayLogs(logs);
}
......@@ -77,27 +79,18 @@ namespace Linphone.Views
private async void refresh_Click_1(object sender, EventArgs e)
{
Browser.InvokeScript("clean");
string logs = await ReadLogs();
logs = await ReadLogs();
FormatAndDisplayLogs(logs);
}
private async void email_Click_1(object sender, EventArgs e)
private void email_Click_1(object sender, EventArgs e)
{
try
{
// Limit the amount of linphone logs to the last 50ko
string logs = await ReadLogs();
if (logs.Length > 50000)
{
logs = logs.Substring(logs.Length - 50000);
}
EmailComposeTask email = new EmailComposeTask();
email.To = "linphone-wphone@belledonne-communications.com";
email.Subject = "Logs report";
email.Body = logs;
email.Show();
}
catch (Exception) { }
string body = logs.Length > 32000 ? logs.Substring(logs.Length - 32000) : logs;
EmailComposeTask email = new EmailComposeTask();
email.To = "linphone-wphone@belledonne-communications.com";
email.Subject = "Logs report";
email.Body = body;
email.Show();
}
private void BuildLocalizedApplicationBar()
......
......@@ -65,6 +65,8 @@ namespace Linphone
reportIssueDialog.Show();
}
BugCollector.DeleteLinphoneLogFileIfFileTooBig();
StatusBar = status;
BasePage.StatusBar.RefreshStatus(LinphoneManager.Instance.LastKnownState);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment