Beispiel #1
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);
            }
        }
Beispiel #2
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()();
                }
            });
        }
Beispiel #3
0
        public Log()
        {
            Channel = new LoggingChannel("DroneLogChannel", new LoggingChannelOptions());
            Session = new FileLoggingSession("Drone Session");

            Session.AddLoggingChannel(Channel, LoggingLevel.Information);
        }
        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);
        }
Beispiel #5
0
        private void InitiateLogger()
        {
            _filelogSession = new FileLoggingSession("DDPaiDashSession");
            _logChannel     = new LoggingChannel("DDPaiDashChannel");
            _filelogSession.AddLoggingChannel(_logChannel);

            CoreApplication.UnhandledErrorDetected += CoreApplication_UnhandledErrorDetected;
        }
Beispiel #6
0
        public void StartLogging()
        {
            CheckDisposed();

            if (session == null)
            {
                session = new FileLoggingSession(DEFAULT_SESSION_NAME);
                session.LogFileGenerated += LogFileGenerateHandler;
            }
            session.AddLoggingChannel(channel, LoggingLevel.Verbose);
        }
Beispiel #7
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);
            }
        }