/// <summary> /// This handler is called by the FileLoggingSession instance when a log /// file reaches a size of 256MB. When FileLoggingSession calls this handler, /// it's effectively giving the developer a chance to take ownership of the /// log file. Typically, this handler should move or rename the log file. /// Note that once this handler has returned, the FileLoggingSession is free /// to reuse the original log file name for a new log file at any time. /// </summary> /// <param name="sender">The FileLoggingSession which has generated a new file.</param> /// <param name="args">Contains a StorageFile field LogFileGeneratedEventArgs.File representing the new log file.</param> private async void LogFileGeneratedHandler(IFileLoggingSession sender, LogFileGeneratedEventArgs args) { LogFileGeneratedCount++; StorageFolder folder = await ApplicationData.Current.LocalFolder.CreateFolderAsync(LOG_FILE_FOLDER_NAME, CreationCollisionOption.OpenIfExists); string newLogFileName = $"Log-{DateTime.Now.GetTimeStamp()}.etl"; await args.File.MoveAsync(folder, newLogFileName); if (IsPreparingForSuspend == false) { StatusChanged?.Invoke(this, new LoggingScenarioEventArgs(LoggingScenarioEventType.LogFileGenerated, System.IO.Path.Combine(folder.Path, newLogFileName))); } }
/// <summary> /// This handler is called by the FileLoggingSession instance when a log file reaches a size /// of 256MB. When FileLoggingSession calls this handler, it's effectively giving the /// developer a chance to own the log file. /// </summary> /// <param name="sender"> /// The FileInfoLoggingSession to the this.localFileLogSession which has generated a new file. /// </param> /// <param name="args"> /// The LogFileGeneratedEventArgs instance which contains a StorageFile field /// LogFileGeneratedEventArgs.File representing the new log file. /// </param> private async void LogFileGeneratedHandler(IFileLoggingSession sender, LogFileGeneratedEventArgs args) { LogFileGeneratedCount++; StorageFolder sampleAppDefinedLogFolder = await ApplicationData.Current.LocalFolder.CreateFolderAsync( CommonConstants.LogAppLogFolderName, CreationCollisionOption.OpenIfExists); string newLogFileName = string.Format(CultureInfo.CurrentCulture, "{0}-{1}.etl", CommonConstants.LogAppLogFileBaseName, GetTimeStamp()); await args.File.MoveAsync(sampleAppDefinedLogFolder, newLogFileName); // TODO fu why this code exists if (IsPreparingForSuspend == false) { string // newLogFileFullPathName = System.IO.Path.Combine(sampleAppDefinedLogFolder.Path, // newLogFileName); } }
private async void LogFileGenerateHandler(IFileLoggingSession sender, LogFileGeneratedEventArgs args) { StorageFolder sampleAppDefinedLogFolder = await ApplicationData.Current.LocalFolder.CreateFolderAsync(APP_LOG_FILE_FOLDER_NAME, CreationCollisionOption.OpenIfExists); string newLogFileName = "Log-" + GetTimeStamp() + ".etl"; await args.File.MoveAsync(sampleAppDefinedLogFolder, newLogFileName); if (IsPreparingForSuspend == false) { if (StatusChanged != null) { string newLogFileFullPathName = System.IO.Path.Combine(sampleAppDefinedLogFolder.Path, newLogFileName); StatusChanged.Invoke(this, new FileLogEventArgs(FileLogEventType.LogFileGenerated, newLogFileFullPathName)); } } }
/// <summary> /// This handler is called by the FileLoggingSession instance when a log /// file reaches a size of 256MB. When FileLoggingSession calls this handler, /// it's effectively giving the developer a chance to own the log file. /// </summary> /// <param name="sender">The IFileLoggingSession to the session which has generated a new file.</param> /// <param name="args">The LogFileGeneratedEventArgs instance which contains a StorageFile field LogFileGeneratedEventArgs.File representing the new log file.</param> private async void LogFileGeneratedHandler(IFileLoggingSession sender, LogFileGeneratedEventArgs args) { LogFileGeneratedCount++; StorageFolder sampleAppDefinedLogFolder = await ApplicationData.Current.LocalFolder.CreateFolderAsync(OUR_SAMPLE_APP_LOG_FILE_FOLDER_NAME, CreationCollisionOption.OpenIfExists); string newLogFileName = string.Format("{0}-{1}.etl", LOG_FILE_BASE_FILE_NAME, GetTimeStamp()); await args.File.MoveAsync(sampleAppDefinedLogFolder, newLogFileName); if (IsPreparingForSuspend == false) { if (StatusChanged != null) { string newLogFileFullPathName = System.IO.Path.Combine(sampleAppDefinedLogFolder.Path, newLogFileName); StatusChanged.Invoke(this, new LoggingScenarioEventArgs(LoggingScenarioEventType.LogFileGenerated, newLogFileFullPathName)); } } }
private GALogger() { #if DEBUG debugEnabled = true; #endif #if WINDOWS_UWP || WINDOWS_WSA session = new FileLoggingSession("ga-session"); #if WINDOWS_UWP var options = new LoggingChannelOptions(); logger = new LoggingChannel("ga-channel", options); #else logger = new LoggingChannel("ga-channel"); #endif session.AddLoggingChannel(logger); LogManagerFactory.DefaultConfiguration.AddTarget(LogLevel.Trace, LogLevel.Fatal, new StreamingFileTarget()); log = LogManagerFactory.DefaultLogManager.GetLogger <GALogger>(); #elif MONO logger = LogManager.GetCurrentClassLogger(); var config = new LoggingConfiguration(); var consoleTarget = new ColoredConsoleTarget(); config.AddTarget("console", consoleTarget); var fileTarget = new FileTarget(); config.AddTarget("file", fileTarget); consoleTarget.Layout = @"${date:format=HH\:mm\:ss} ${logger} ${message}"; fileTarget.FileName = GADevice.WritablePath + Path.DirectorySeparatorChar + "ga_log.txt"; fileTarget.Layout = "${message}"; var rule1 = new LoggingRule("*", LogLevel.Debug, consoleTarget); config.LoggingRules.Add(rule1); var rule2 = new LoggingRule("*", LogLevel.Debug, fileTarget); config.LoggingRules.Add(rule2); LogManager.Configuration = config; #endif #if WINDOWS_PHONE logger = new ILogger(); #endif }
private void LogFileGeneratedHandler(IFileLoggingSession sender, LogFileGeneratedEventArgs args) { // TODO }
public IFileLoggingSessionEvents(IFileLoggingSession This) { this.This = This; }