/// <summary> /// Print out the debug message. /// </summary> /// <param name="msg">Message to print</param> /// <param name="level">Debug level of message</param> public async static void DebugPrint(string msg, LogLevel level) { if (ShouldLog(level)) { msg = ComposeMessage(msg, level); #if DEBUG // Only do this in debug Debug.WriteLine(msg); #endif #if !DEBUG // Never crash in release build try { #endif if (eventListener == null) { eventListener = new StorageFileEventListener(); eventListener.EnableEvents(LogEventSource.Log, EventLevel.LogAlways); await eventListener.InitializeAsync(); } LogEventSource.Log.Debug(msg); #if !DEBUG } catch (Exception ex) { Debug.WriteLine(ex.ToString()); } #endif } }
public App() { InitializeComponent(); SplashFactory = (e) => new Views.Splash(e); #if DEBUG DebugSettings.EnableFrameRateCounter = true; #endif #region App Settings // some settings must be set in app.constructor var settings = SettingsService.Instance; RequestedTheme = settings.AppTheme; CacheMaxDuration = settings.CacheMaxDuration; ShowShellBackButton = settings.UseShellBackButton; #endregion // Initialize logger. informationListener = new StorageFileEventListener("info"); verboseListener = new StorageFileEventListener("verbose"); // Enable events for loggers. informationListener.EnableEvents(EventLog.Log, EventLevel.Informational); verboseListener.EnableEvents(EventLog.Log, EventLevel.LogAlways); // Clear FutureAccessList as it has a max limit of 1000. ClearFutureAccessList(); // Log startup. LifecycleLog.AppStarting(); }
/// <summary> /// Initializes the singleton application object. This is the first line of authored code /// executed, and as such is the logical equivalent of main() or WinMain(). /// </summary> public App() { this.InitializeComponent(); this.Suspending += OnSuspending; System.Diagnostics.Tracing.EventListener verboseListener = new StorageFileEventListener("MyListenerVerbose"); System.Diagnostics.Tracing.EventListener informationListener = new StorageFileEventListener("MyListenerInformation"); verboseListener.EnableEvents(MetroEventSource.Log, System.Diagnostics.Tracing.EventLevel.Verbose); informationListener.EnableEvents(MetroEventSource.Log, System.Diagnostics.Tracing.EventLevel.Informational); }
/// <summary> /// 在應用程式由終端使用者正常啟動時叫用。當啟動應用 /// 將在例如啟動應用程式時使用以開啟特定檔案。 /// </summary> /// <param name="e">關於啟動要求和處理序的詳細資料。</param> protected override void OnLaunched(LaunchActivatedEventArgs e) { Frame rootFrame = Window.Current.Content as Frame; // 當視窗中已有內容時,不重複應用程式初始化, // 只確定視窗是作用中 if (rootFrame == null) { // 建立框架做為巡覽內容,並巡覽至第一頁 rootFrame = new Frame(); rootFrame.NavigationFailed += OnNavigationFailed; if (e.PreviousExecutionState == ApplicationExecutionState.Terminated) { //TODO: 從之前暫停的應用程式載入狀態 } // 將框架放在目前視窗中 Window.Current.Content = rootFrame; } if (e.PrelaunchActivated == false) { if (rootFrame.Content == null) { // 在巡覽堆疊未還原時,巡覽至第一頁, // 設定新的頁面,方式是透過傳遞必要資訊做為巡覽 // 參數 EventListener debugListener = new StorageFileEventListener("DebugLog"); debugListener.EnableEvents(MetroEventSource.Log, EventLevel.Verbose); rootFrame.Navigate(typeof(WindowsPage), e.Arguments); } // 確定目前視窗是作用中 Window.Current.Activate(); } var titleBar = ApplicationView.GetForCurrentView().TitleBar; // Set active window colors titleBar.ForegroundColor = Windows.UI.Colors.White; titleBar.BackgroundColor = Windows.UI.Colors.Black; titleBar.ButtonForegroundColor = Windows.UI.Colors.White; titleBar.ButtonBackgroundColor = Windows.UI.Colors.Black; titleBar.ButtonHoverForegroundColor = Windows.UI.Colors.White; titleBar.ButtonHoverBackgroundColor = Windows.UI.Colors.Black; titleBar.ButtonPressedForegroundColor = Windows.UI.Colors.Gray; titleBar.ButtonPressedBackgroundColor = Windows.UI.Colors.Black; // Set inactive window colors titleBar.InactiveForegroundColor = Windows.UI.Colors.Gray; titleBar.InactiveBackgroundColor = Windows.UI.Colors.Black; titleBar.ButtonInactiveForegroundColor = Windows.UI.Colors.Gray; titleBar.ButtonInactiveBackgroundColor = Windows.UI.Colors.Black; }
/// <summary> /// Invoked when the application is launched normally by the end user. Other entry points /// will be used when the application is launched to open a specific file, to display /// search results, and so forth. /// </summary> /// <param name="e">Details about the launch request and process.</param> protected override void OnLaunched(LaunchActivatedEventArgs e) { #if DEBUG if (System.Diagnostics.Debugger.IsAttached) { this.DebugSettings.EnableFrameRateCounter = true; } #endif Frame rootFrame = Window.Current.Content as Frame; // Do not repeat app initialization when the Window already has content, // just ensure that the window is active if (rootFrame == null) { // Create a Frame to act as the navigation context and navigate to the first page rootFrame = new Frame(); // TODO: change this value to a cache size that is appropriate for your application rootFrame.CacheSize = 1; if (e.PreviousExecutionState == ApplicationExecutionState.Terminated) { // TODO: Load state from previously suspended application } // Place the frame in the current Window Window.Current.Content = rootFrame; } if (rootFrame.Content == null) { // First time execution, initialize the logger // These go here: C:\Users\Ben\AppData\Local\Packages\3c9f50a4-a4cf-4130-baf6-55febc10ca72_z6xh1x1kg5n3j\LocalState EventListener verboseListener = new StorageFileEventListener("MyListenerVerbose"); EventListener informationListener = new StorageFileEventListener("MyListenerInformation"); verboseListener.EnableEvents(KinectPhotobooth.Log.EventSource.Log, EventLevel.Verbose); informationListener.EnableEvents(KinectPhotobooth.Log.EventSource.Log, EventLevel.Informational); // When the navigation stack isn't restored navigate to the first page, // configuring the new page by passing required information as a navigation // parameter if (!rootFrame.Navigate(typeof(MainPage), e.Arguments)) { throw new Exception("Failed to create initial page"); } } KinectPhotobooth.Log.EventSource.Log.Info("Current Window is activating"); // Ensure the current window is active Window.Current.Activate(); }
private async Task SetupEventListener() { this.DiagnosticsFile = await ApplicationData.Current.LocalFolder.CreateFileAsync( $"diag-{DateTime.Now:dd-MM-yyyy}.txt", CreationCollisionOption.OpenIfExists); this.listener = new StorageFileEventListener(this.DiagnosticsFile); this.listener.EnableEvents(EventLogger.Current, EventLevel.Verbose); EventLogger.Current.WriteInfo("Application diagnostics initialized."); }
public static InMemoryBlobCache RegisterComponentsAndReturnInMemoryBlobCache() { EventListener verboseListener = new StorageFileEventListener("MyListenerVerbose1"); EventListener informationListener = new StorageFileEventListener("MyListenerInformation1"); verboseListener.EnableEvents(KrossEventSource.Log, EventLevel.Error); Locator.CurrentMutable.RegisterConstant(KrossEventSource.Log, typeof(KrossEventSource)); var blobCache = new InMemoryBlobCache(); Locator.CurrentMutable.RegisterConstant(blobCache, typeof(IBlobCache), "UserAccount"); Locator.CurrentMutable.Register(() => new KrossLogger(), typeof(ILogger)); return(blobCache); }
protected async override void OnLaunched(LaunchActivatedEventArgs args) { if (args == null) { throw new ArgumentNullException("args"); } RegisterExceptionHandlingSynchronizationContext(); var rootFrame = Window.Current.Content as Frame; // Do not repeat app initialization when the Window already has content, // just ensure that the window is active if (rootFrame == null) { // Create a Frame to act as the navigation context and navigate to the first page rootFrame = new Frame(); if (args.PreviousExecutionState == ApplicationExecutionState.Terminated) { // TODO: Load state from previously suspended application } SettingsPane.GetForCurrentView().CommandsRequested += App_CommandsRequested; // Place the frame in the current Window Window.Current.Content = rootFrame; } if (rootFrame.Content == null) { m_verboseListener = new StorageFileEventListener("Verbose"); m_verboseListener.EnableEvents(AppEventSource.Instance, EventLevel.Verbose); // When the navigation stack isn't restored navigate to the first page, // configuring the new page by passing required information as a navigation // parameter var appViewModel = await CreateAppViewModel(); appViewModel.NavigateToMainPage(args.Arguments); } AppEventSource.Instance.Debug("Activating"); // Ensure the current window is active Window.Current.Activate(); }
/// <summary> /// Invoked when the application is launched normally by the end user. Other entry points /// will be used when the application is launched to open a specific file, to display /// search results, and so forth. /// </summary> /// <param name="args">Details about the launch request and process.</param> protected override void OnLaunched(LaunchActivatedEventArgs args) { Frame rootFrame = Window.Current.Content as Frame; // Do not repeat app initialization when the Window already has content, // just ensure that the window is active if (rootFrame == null) { // Create a Frame to act as the navigation context and navigate to the first page rootFrame = new Frame(); if (args.PreviousExecutionState == ApplicationExecutionState.Terminated) { //TODO: Load state from previously suspended application } // Place the frame in the current Window Window.Current.Content = rootFrame; } if (rootFrame.Content == null) { // First time execution, initialize the logger EventListener verboseListener = new StorageFileEventListener("MyListenerVerbose"); EventListener informationListener = new StorageFileEventListener("MyListenerInformation"); verboseListener.EnableEvents(MetroEventSource.Log, EventLevel.Verbose); informationListener.EnableEvents(MetroEventSource.Log, EventLevel.Informational); // When the navigation stack isn't restored navigate to the first page, // configuring the new page by passing required information as a navigation // parameter if (!rootFrame.Navigate(typeof(MainPage), args.Arguments)) { throw new Exception("Failed to create initial page"); } } MetroEventSource.Log.Info("Current Window is activating"); // Ensure the current window is active Window.Current.Activate(); }
/// <summary> /// Invoked when the application is launched normally by the end user. Other entry points /// will be used such as when the application is launched to open a specific file. /// </summary> /// <param name="e">Details about the launch request and process.</param> protected override void OnLaunched(LaunchActivatedEventArgs e) { #if DEBUG if (System.Diagnostics.Debugger.IsAttached) { this.DebugSettings.EnableFrameRateCounter = true; } #endif Frame rootFrame = Window.Current.Content as Frame; // Do not repeat app initialization when the Window already has content, // just ensure that the window is active if (rootFrame == null) { Debug.WriteLine("Log location: " + ApplicationData.Current.LocalFolder.Path); EventListener verboseListener = new StorageFileEventListener("Log"); verboseListener.EnableEvents(OneWireEventSource.Log, EventLevel.Verbose); // Create a Frame to act as the navigation context and navigate to the first page rootFrame = new Frame(); rootFrame.NavigationFailed += OnNavigationFailed; if (e.PreviousExecutionState == ApplicationExecutionState.Terminated) { //TODO: Load state from previously suspended application } // Place the frame in the current Window Window.Current.Content = rootFrame; } if (rootFrame.Content == null) { // When the navigation stack isn't restored navigate to the first page, // configuring the new page by passing required information as a navigation // parameter rootFrame.Navigate(typeof(MainPage), e.Arguments); } // Ensure the current window is active Window.Current.Activate(); }
private void SetupLogging() { string enable = OneWireAccessProvider.getProperty("onewire.debug"); if (!string.ReferenceEquals(enable, null) && enable.ToLower().Equals("true")) { DEBUG = true; } else { DEBUG = false; } string logFile = OneWireAccessProvider.getProperty("onewire.debug.logfile"); if (!string.ReferenceEquals(logFile, null)) { if (DEBUG) { // ignore any absolute path provided, only use filename string[] strtok = logFile.Split(new char[] { '\\' }); StorageFolder localFolder = ApplicationData.Current.LocalFolder; string logFilePath = localFolder.Path + "\\" + strtok[strtok.Length - 1].Trim(); Debug.WriteLine("Log location: " + ApplicationData.Current.LocalFolder.Path); EventListener listener = new StorageFileEventListener(logFile); listener.EnableEvents(OneWireEventSource.Log, EventLevel.Verbose); } else { Debug.WriteLine("Log location: " + ApplicationData.Current.LocalFolder.Path); EventListener listener = new StorageFileEventListener("log"); listener.EnableEvents(OneWireEventSource.Log, EventLevel.Informational); } } else { Debug.WriteLine("Log location: " + ApplicationData.Current.LocalFolder.Path); EventListener listener = new StorageFileEventListener("log"); listener.EnableEvents(OneWireEventSource.Log, EventLevel.Informational); } }
/// <summary> /// Initializes the singleton application object. This is the first line of authored code /// executed, and as such is the logical equivalent of main() or WinMain(). /// </summary> public App() { PruneLogsFiles(); string logFileName = DateTime.Now.ToString("yyyy-MM-dd-HH-mm-ss"); EventListener informationListener = new StorageFileEventListener("AppLog-" + logFileName); informationListener.EnableEvents(MetroEventSource.Log, EventLevel.Informational); this.InitializeComponent(); this.Suspending += OnSuspending; this.Resuming += OnResume; //notifications.Add(new Notification() { Title = "Test Title", Message = "This is a test" }); notificationTimer.Tick += NotificationTimer_Tick; notificationTimer.Interval = TimeSpan.FromSeconds(3); notificationTimer.Start(); MetroEventSource.Log.Info("App Started"); }
/// <summary> /// Invoked when the application is launched normally by the end user. Other entry points /// will be used when the application is launched to open a specific file, to display /// search results, and so forth. /// </summary> /// <param name="args">Details about the launch request and process.</param> protected override async void OnLaunched(LaunchActivatedEventArgs args) { //progress bar atualizar inicial. try { if (args.PreviousExecutionState != ApplicationExecutionState.Running) { bool loadState = (args.PreviousExecutionState == ApplicationExecutionState.Terminated); ExtendedSplash extendedSplash = new ExtendedSplash(args.SplashScreen, loadState); Window.Current.Content = extendedSplash; } Window.Current.Activate(); //Verificar onde atualizar pela primeira vez. Preferencias preferencias = await Core.GetSPreferencias(); //Verfica se existe preferencia registra, caso nao cria uma padrão. var sucesso = await Core.AtualizacaoAutomatica(preferencias.TempoAtualizacao); //Core.AtualizarObjetosDisco(); if (sucesso != null && sucesso.Objetos != null) { } var sucessoHistorico = await Core.GravarObjetoHistorico(); if (sucessoHistorico) { } } catch (Exception ex) { //Entities.LOG.MetroEventSource.Log.Error(ex.Message + "#" + ex.InnerException + "APP.cs" + "#" + "OnLaunched"); } // Register handler for CommandsRequested events from the settings pane SettingsPane.GetForCurrentView().CommandsRequested += OnCommandsRequested; Frame rootFrame = Window.Current.Content as Frame; // Do not repeat app initialization when the Window already has content, // just ensure that the window is active if (rootFrame == null) { // Create a Frame to act as the navigation context and navigate to the first page rootFrame = new Frame(); //Associate the frame with a SuspensionManager key SuspensionManager.RegisterFrame(rootFrame, "AppFrame"); if (args.PreviousExecutionState == ApplicationExecutionState.Terminated) { // Restore the saved session state only when appropriate try { await SuspensionManager.RestoreAsync(); } catch (SuspensionManagerException) { //Something went wrong restoring state. //Assume there is no state and continue } } // Place the frame in the current Window Window.Current.Content = rootFrame; } if (rootFrame.Content == null) { // First time execution, initialize the logger try { EventListener verboseListener = new StorageFileEventListener("LOG_MyListenerVerbose"); EventListener informationListener = new StorageFileEventListener("LOG_MyListenerInformation"); verboseListener.EnableEvents(MetroEventSource.Log, EventLevel.Verbose); informationListener.EnableEvents(MetroEventSource.Log, EventLevel.Informational); } catch (Exception ex) { } // When the navigation stack isn't restored navigate to the first page, // configuring the new page by passing required information as a navigation // parameter if (!rootFrame.Navigate(typeof(GroupedItemsPage), "AllGroups")) { throw new Exception("Failed to create initial page"); } } // Ensure the current window is active Window.Current.Activate(); }