public static async void LogMessageToFile(string message, LoggingLevel level)
        {
            // Initialization
            if (fileLoggingSession == null)
            {
                fileLoggingSession = new FileLoggingSession("NewTestamentLogSession");
            }
            using (var loggingChannel = new LoggingChannel(
                       "NewTestamentLogSession",
                       new LoggingChannelOptions(new Guid("2e0582f3-d1b6-516a-00e3-9fd79ef95200")))) // Join a provider group
            {
                // The Id is generated by hashing the string "SampleProvider".
                // channel.Id == eff1e128-4903-5093-096a-bdc29b38456f
                fileLoggingSession.AddLoggingChannel(loggingChannel);
                // Log messages
                loggingChannel.LogMessage(message, level);
            }
            var file = await fileLoggingSession.CloseAndSaveToFileAsync();

            StorageFolder sampleAppDefinedLogFolder =
                await ApplicationData.Current.LocalFolder.CreateFolderAsync("Logs", CreationCollisionOption.OpenIfExists);

            string newLogFileName = "Log1-" + TimeStamp.Now() + ".etl";
            await file.MoveAsync(sampleAppDefinedLogFolder, newLogFileName);
        }
Esempio n. 2
0
        public async Task PreparedToSuspend()
        {
            CheckDisposed();

            if (session != null)
            {
                IsPreparingForSuspend = true;

                try
                {
                    string finalFileBeforeSuspend = await CloseSessionSaveFinalLogFile();

                    session.Dispose();
                    session = null;
                    ApplicationData.Current.LocalSettings.Values[LOGGING_ENABLED_SETTING_KEY_NAME]            = true;
                    ApplicationData.Current.LocalSettings.Values[LOGFILEGIEN_BEFORE_SUSPEND_SETTING_KEY_NAME] = finalFileBeforeSuspend;
                }
                finally
                {
                    IsPreparingForSuspend = false;
                }
            }
            else
            {
                ApplicationData.Current.LocalSettings.Values[LOGGING_ENABLED_SETTING_KEY_NAME]            = false;
                ApplicationData.Current.LocalSettings.Values[LOGFILEGIEN_BEFORE_SUSPEND_SETTING_KEY_NAME] = null;
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Starts the logging.
        /// </summary>
        /// <param name="logToFile">
        /// if set to <c>true</c> [log to file].
        /// </param>
        public void StartLogging(bool logToFile)
        {
            CheckDisposed();

            // If not this.localFileLogSession exists, create one.
            // NOTE: There are use cases where an application may want to create only a channel for
            // sessions outside of the application itself. See MSDN for details. This sample is the
            // common scenario of an app logging events which it wants to place in its own log file,
            // so it creates a this.localFileLogSession and channel as a pair. The channel is
            // created during construction of this LoggingScenario class so it already exists by the
            // time this function is called.
            if (localFileLogSession == null)
            {
                if (logToFile == true)
                {
                    localFileLogSession = new FileLoggingSession(CommonConstants.LogDefaultSessionName);
                    localFileLogSession.LogFileGenerated += LogFileGeneratedHandler;

                    // Log all messages using Verbose filter
                    localFileLogSession.AddLoggingChannel(logChannel, LoggingLevel.Verbose);
                }
            }
            else
            {
                localFileLogSession = new FileLoggingSession(CommonConstants.LogDefaultSessionName);
            }
        }
Esempio n. 4
0
        public Log()
        {
            Channel = new LoggingChannel("DroneLogChannel", new LoggingChannelOptions());
            Session = new FileLoggingSession("Drone Session");

            Session.AddLoggingChannel(Channel, LoggingLevel.Information);
        }
Esempio n. 5
0
        /// <summary>
        /// </summary>
        private Logs()
        {
            Create();
            //Creating channel for logging in Holo Web portail
            loggingChannel = new LoggingChannel(Application.productName, null, new Guid());
            fls            = new FileLoggingSession(Application.productName);
            fls.AddLoggingChannel(loggingChannel);

            WritingTask = Task.Run(async() => {
                //While logs instance exist, wait for a task for writing
                while (Writing)
                {
                    if (queue.Count > 0)
                    {
                        queue.Dequeue()();
                    }
                    else
                    {
                        await Task.Delay(1000);
                    }
                }
                // Clearing the queue before disposing
                while (queue.Count < 0)
                {
                    queue.Dequeue()();
                }
            });
        }
Esempio n. 6
0
        private void InitiateLogger()
        {
            _filelogSession = new FileLoggingSession("DDPaiDashSession");
            _logChannel     = new LoggingChannel("DDPaiDashChannel");
            _filelogSession.AddLoggingChannel(_logChannel);

            CoreApplication.UnhandledErrorDetected += CoreApplication_UnhandledErrorDetected;
        }
Esempio n. 7
0
        public void StartLogging()
        {
            CheckDisposed();

            if (session == null)
            {
                session = new FileLoggingSession(DEFAULT_SESSION_NAME);
                session.LogFileGenerated += LogFileGenerateHandler;
            }
            session.AddLoggingChannel(channel, LoggingLevel.Verbose);
        }
        // Constructor
        public MainPage()
        {
            InitializeComponent();

            this.sts = StsFactory.CreateSts(StsType.AAD);

            this.fls = new FileLoggingSession("Test File Logging Session");
            this.fls.AddLoggingChannel(AdalTrace.AdalLoggingChannel, LoggingLevel.Verbose);

            this.ls = new LoggingSession("Test Logging Session");
            this.ls.AddLoggingChannel(AdalTrace.AdalLoggingChannel, LoggingLevel.Verbose);
        }
        // Constructor
        public MainPage()
        {
            InitializeComponent();

            this.sts = StsFactory.CreateSts(StsType.AAD);

            this.fls = new FileLoggingSession("Test File Logging Session");
            this.fls.AddLoggingChannel(AdalTrace.AdalLoggingChannel, LoggingLevel.Verbose);

            this.ls = new LoggingSession("Test Logging Session");
            this.ls.AddLoggingChannel(AdalTrace.AdalLoggingChannel, LoggingLevel.Verbose);
        }
Esempio n. 10
0
 protected virtual void Dispose(bool disposing)
 {
     if (isDisposed == false)
     {
         isDisposed = true;
         if (channel != null)
         {
             channel.Dispose();
             channel = null;
         }
         if (session != null)
         {
             session.Dispose();
             session = null;
         }
     }
 }
Esempio n. 11
0
        public async Task <bool> ToggleLoggingEnabledDisabledAsync()
        {
            CheckDisposed();
            IsBusy = true;

            try
            {
                bool enabled;

                if (session != null)
                {
                    string finalLogFilePath = await CloseSessionSaveFinalLogFile();

                    session.Dispose();
                    session = null;
                    if (StatusChanged != null)
                    {
                        StatusChanged.Invoke(this, new FileLogEventArgs(FileLogEventType.LogFileGeneratedAtDisable, finalLogFilePath));
                    }
                    ApplicationData.Current.LocalSettings.Values[LOGGING_ENABLED_SETTING_KEY_NAME] = false;
                    enabled = false;
                }

                else
                {
                    StartLogging();
                    ApplicationData.Current.LocalSettings.Values[LOGGING_ENABLED_SETTING_KEY_NAME] = true;
                    enabled = true;
                }

                if (StatusChanged != null)
                {
                    StatusChanged.Invoke(this, new FileLogEventArgs(enabled));
                }

                return(enabled);
            }
            finally
            {
                IsBusy = false;
            }
        }
Esempio n. 12
0
        public MainPage()
        {
            InitializeComponent();
            Current = this;

            try
            {
                loggingSessionTests = new FileLoggingSession("SensorExplorerLogTests");
                loggingChannelTests = new LoggingChannel("SensorExplorerLogTests", null);
                loggingSessionTests.AddLoggingChannel(loggingChannelTests);

                loggingSessionView = new FileLoggingSession("SensorExplorerLogView");
                loggingChannelView = new LoggingChannel("SensorExplorerLogView", null);
                loggingSessionView.AddLoggingChannel(loggingChannelView);
            }
            catch (Exception e)
            {
                NotifyUser(e.Message, NotifyType.ErrorMessage);
            }
        }
Esempio n. 13
0
        private void Dispose(bool disposing)
        {
            if (isDisposed == false)
            {
                isDisposed = true;

                if (disposing)
                {
                    if (channel != null)
                    {
                        channel.Dispose();
                        channel = null;
                    }

                    if (session != null)
                    {
                        session.Dispose();
                        session = null;
                    }
                }
            }
        }
Esempio n. 14
0
        /// <summary>
        /// Releases unmanaged and - optionally - managed resources.
        /// </summary>
        /// <param name="disposing">
        /// <c>true</c> to release both managed and unmanaged resources; <c>false</c> to release
        /// only unmanaged resources.
        /// </param>
        protected virtual void Dispose(bool disposing)
        {
            if (loggingSessionDisposed == false)
            {
                loggingSessionDisposed = true;

                if (disposing)
                {
                    if (logChannel != null)
                    {
                        logChannel.Dispose();
                        logChannel = null;
                    }

                    if (localFileLogSession != null)
                    {
                        localFileLogSession.Dispose();
                        localFileLogSession = null;
                    }
                }
            }
        }
        public void StartLogging()
        {
            CheckDisposed();

            // If no session exists, create one.
            // NOTE: There are use cases where an application
            // may want to create only a channel for sessions outside
            // of the application itself. See MSDN for details. This
            // sample is the common scenario of an app logging events
            // which it wants to place in its own log file, so it creates
            // a session and channel as a pair. The channel is created
            // during construction of this LoggingScenario class so
            // it already exsits by the time this function is called.
            if (session == null)
            {
                session = new FileLoggingSession(DEFAULT_SESSION_NAME);
                session.LogFileGenerated += LogFileGeneratedHandler;
            }

            // This sample adds the channel at level "warning" to
            // demonstrated how messages logged at more verbose levels
            // are ignored by the session.
            session.AddLoggingChannel(channel, LoggingLevel.Warning);
        }
Esempio n. 16
0
        /// <summary>
        /// SAMPLE CODE Prepare this scenario for suspend.
        /// </summary>
        /// <returns>
        /// Void Task.
        /// </returns>
        public async Task PrepareToSuspendAsync()
        {
            CheckDisposed();

            if (localFileLogSession != null)
            {
                IsPreparingForSuspend = true;

                try
                {
                    // Before suspend, save any final log file.
                    string finalFileBeforeSuspend = await CloseSessionSaveFinalLogFile();

                    localFileLogSession.Dispose();
                    localFileLogSession = null;

                    // Save values used when the app is resumed or started later. Logging is enabled.
                    CommonLocalSettings.LoggingEnabled = true;

                    // Save the log file name saved at suspend so the sample UI can be updated on
                    // resume with that information.
                    ApplicationData.Current.LocalSettings.Values["LogFileGeneratedBeforeSuspend"] = finalFileBeforeSuspend;
                }
                finally
                {
                    IsPreparingForSuspend = false;
                }
            }
            else
            {
                // Save values used when the app is resumed or started later. Logging is not enabled
                // and no log file was saved.
                CommonLocalSettings.LoggingEnabled = false;
                ApplicationData.Current.LocalSettings.Values["LogFileGeneratedBeforeSuspend"] = null;
            }
        }
        public void StartLogging()
        {
            CheckDisposed();

            // If no session exists, create one.
            // NOTE: There are use cases where an application
            // may want to create only a channel for sessions outside
            // of the application itself. See MSDN for details. This
            // sample is the common scenario of an app logging events
            // which it wants to place in its own log file, so it creates
            // a session and channel as a pair. The channel is created 
            // during construction of this LoggingScenario class so 
            // it already exsits by the time this function is called. 
            if (session == null)
            {
                session = new FileLoggingSession(DEFAULT_SESSION_NAME);
                session.LogFileGenerated += LogFileGeneratedHandler;
            }

            // This sample adds the channel at level "warning" to 
            // demonstrated how messages logged at more verbose levels
            // are ignored by the session. 
            session.AddLoggingChannel(channel, LoggingLevel.Warning);
        }
 public FileLoggingSessionEvents(FileLoggingSession This)
 {
     this.This = This;
 }
        protected virtual void Dispose(bool disposing)
        {
            if (isDisposed == false)
            {
                isDisposed = true;

                if (disposing)
                {
                    if (channel != null)
                    {
                        channel.Dispose();
                        channel = null;
                    }

                    if (session != null)
                    {
                        session.Dispose();
                        session = null;
                    }
                }
            }
        }