private static string ZipData(string pathToLog, string pathToWrapperLog, string pathToSdkLog, string pathToDb, string userName, string hashedPass, string esn, string previousEsn) { string str = AppLog.GenerateNewFilePath("package"); using (FileStream fileStream = File.Create(str)) { ZipOutputStream zipOutputStream = new ZipOutputStream(fileStream) { Password = "******" }; zipOutputStream.SetLevel(3); AppLog.PutStreamToZip("z", zipOutputStream, new MemoryStream(Encoding.UTF8.GetBytes(AppLog.GenerateEncryptedUserDetails(userName, hashedPass, esn, previousEsn)))); AppLog.PutStreamToZip("l", zipOutputStream, File.OpenRead(pathToLog)); AppLog.PutStreamToZip("d", zipOutputStream, File.OpenRead(pathToDb)); if (File.Exists(pathToWrapperLog)) { AppLog.PutStreamToZip("wl", zipOutputStream, File.Open(pathToWrapperLog, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)); } if (File.Exists(pathToSdkLog)) { AppLog.PutStreamToZip("sdkl", zipOutputStream, File.Open(pathToSdkLog, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)); } string unityLogFilePath = AppLog.GetUnityLogFilePath(); if (!string.IsNullOrEmpty(unityLogFilePath) && File.Exists(unityLogFilePath)) { AppLog.PutStreamToZip("log", zipOutputStream, File.Open(unityLogFilePath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)); } zipOutputStream.Close(); } return(str); }
public static void Init(bool writeToFile) { if (AppLog._isInited) { return; } Application.logMessageReceivedThreaded += new Application.LogCallback(AppLog.OnLogMessageReceivedThreaded); AppLog._isInited = true; AppLog._fileWriter = new SystemIoFileWriter(); if (Application.platform == RuntimePlatform.IPhonePlayer || Application.platform == RuntimePlatform.Android) { //AppLog._emailSender = new EtceteraMailWriter(); } else { //AppLog._emailSender = new PCMailWriter(); } AppLog._currentFilePath = PlayerPrefs.GetString("CurrentLogFilePathKey"); AppLog._prevFilePath = PlayerPrefs.GetString("PrevLogFilePathKey"); AppLog._currentWrapperLogPath = PlayerPrefs.GetString("CurrentWrapperLogPathKey"); AppLog._prevWrapperLogPath = PlayerPrefs.GetString("PrevWrapperLogPathKey"); AppLog._fileWriter.RemoveFile(AppLog._prevFilePath); AppLog._fileWriter.RemoveFile(AppLog._prevWrapperLogPath); AppLog._prevFilePath = null; AppLog._prevWrapperLogPath = null; if (!string.IsNullOrEmpty(AppLog._currentFilePath)) { AppLog._prevFilePath = AppLog._currentFilePath; } if (!string.IsNullOrEmpty(AppLog._currentWrapperLogPath)) { AppLog._prevWrapperLogPath = AppLog._currentWrapperLogPath; } AppLog._currentFilePath = AppLog.GenerateNewFilePath("txt"); AppLog._currentWrapperLogPath = AppLog.GenerateNewFilePath("txt"); AppLog._writeToFile = writeToFile; PlayerPrefs.SetString("CurrentLogFilePathKey", AppLog._currentFilePath); PlayerPrefs.SetString("PrevLogFilePathKey", AppLog._prevFilePath); PlayerPrefs.SetString("CurrentWrapperLogPathKey", AppLog._currentWrapperLogPath); PlayerPrefs.SetString("PrevWrapperLogPathKey", AppLog._prevWrapperLogPath); }