Logging to Event Viewer on Windows RT 8.1 - windows-store-apps

I am working on an LOB (side-loading) app and I need to log events, crashes to ETW (Event Viewer logs). I see that most suggest writing own file IO wrapper.
With Windows 8.1, we have new logging capabilities in "Windows.Foundation.Diagnostics" which has classes for "LoggingChannel" and "LoggingSession". But the code sample for them still write to the isolated local storage as files:
http://code.msdn.microsoft.com/windowsapps/LoggingSession-Sample-ccd52336
Also, earlier than 8.1, we have "EventSource" and "EventListener" and as per a sample project (http://code.msdn.microsoft.com/windowsapps/Logging-Sample-for-Windows-0b9dffd7/sourcecode?fileId=67472&pathId=1214683397), it also writes to the sample isolated storage as files.
So, my questions are:
Can we utilize new "Windows.Foundation.Diagnostics" classes to write to ETW?
Are ("LoggingChannel" and "LoggingSession") equivalent to ("EventSource" and "EventListener") ultimately?
Will I still have to write C++ component for writing to ETW?
Forum of Microsoft just gave this answer:
It is not designed with such thing in mind.
I also tried using PInvoke for consuming EventRegister, EventWrite C++ functions. The code runs but I have no idea where find the log. The EventRegister only takes GUID as input and I don't know if it can be mapped to EventViewer application.

Short answer to the questions:
Windows.Foundation.Diagnostics.LoggingChannel writes events to ETW. However, it does not give you complete control over the event in the way that EventRegister/EventWrite do.
LoggingChannel is somewhat equivalent to .NET's EventSource. However, LoggingChannel always writes events to ETW, while EventSource can write to ETW but also has capabilities to bypass ETW. LoggingSession is similar in concept to EventListener, except that LoggingSession always receives events from ETW, while EventListener only works with EventSource (bypassing ETW). Note that you can use both LoggingChannel and EventSource in Windows Store apps.
You will have to write C++ code to use ETW if you need more capabilities than LoggingChannel or EventSource provides.
A few other comments based on things you mentioned:
Event Viewer shows data from the Event Log. The Event Log is not the same as ETW. Event Viewer records data from various sources, and ETW is one of the sources that Event Viewer supports. However, Event Viewer does not record all ETW events -- there are billions of ETW events every hour, and it would fill your hard disk if all of them were recorded. To send an ETW event to Event Viewer, you first have to make your event follow certain rules, and then you have to update the Event Viewer settings to watch for your specific event.
Event Log is designed to record events that are of interest to system administrators and system analysis tools. Because of this design, Microsoft requires administrator privileges to change the Event Log configuration. In order to have your events show up in Event Log, you need to have administrator privileges to change Event Log settings to make Event Log listen to your app's ETW events.
LoggingChannel does not support the necessary settings to make your ETW event look the way Event Log expects, so LoggingChannel cannot be used to write to the Event Log.
If you use EventRegister and EventWrite, you can write events in the format that Event Log expects, but you would still need to have administrator privileges to change Event Log settings to accept your events.
Note that EventRegister and EventWrite (and LoggingChannel) are for sending data to ETW. You can send anything you want to ETW, but by default ETW will just ignore it and throw it all away. ETW is the system for routing events from the provider to anybody who is interested in the event. If nobody is interested in the event, it gets thrown away by default.
LoggingChannel writes events out to ETW, but ETW will just drop them unless there is a session to record them. From within your app, you can record the events using LoggingSession. From outside your app, you can record the events using a tool such as xperf or tracelog.
You can use Windows.Foundation.Diagnostics.LoggingChannel from Windows 8.1 to write ETW events with some limitations. In particular: all events from all apps will always use the same provider GUID (4bd2826e-54a1-4ba9-bf63-92b73ea1ac4a), there is no way to access the keyword, channel, task, or opcode features of ETW, and you can only write very simple events. The Windows 8.1 LoggingChannel API is mainly focused on providing a simple string-based logging facility.
Windows 10 adds a bunch of new features, removing many of the limitations. You can use a different provider GUID (so it is easier to record just the events from your app), you can set keywords, tasks, and opcodes, and you can write strongly-typed events (i.e. events with strongly-typed field values instead of just a flat string). The Windows 10 LoggingChannel API allows you to use LoggingChannel for fairly advanced ETW scenarios, though it still works for simple logging.

Related

Google Data Studio - When is resetAuth() being called?

I am having troubles with the resetAuth() function. I implemented it roughly like this example, but I have no idea when it is being called. Adding a console output and observing the Stackdriver Log tells me that this function is never being called during what I would call a normal workflow.
The documentation is weirdly brief and is missing this part about why I need to implement it and when it is being called. Do I need to call resetAuth() manually on some point? Is there a button somewhere that calls this function?
I'm using the AuthType USER_PASS by the way and everything else seems to work just fine after some investigation and debugging.
I found this document called Community Connectors Developer Launch where, among other things, the following it listed (as of 2018-07-30):
What's next: Upcoming changes and improvements
Some of the features and improvements we'll be working on in the
coming months include:
Configuration and Authentication
Capability to execute the resetAuth function of community connectors from within Data Studio.
Does this mean that calling resetAuth() is currently not yet implemented?
resetAuth is called when the user revokes access to the connector via the https://datastudio.google.com/datasources/create endpoint.
There was a bug that caused this function to not be called for certain auth types, but it has been resolved.

Web speech API stops listening after some time passes without input

I'm using the web speech API but once a bit of time passes by (a minute or 2) without any vocal input, it stops listening entirely. I know this because I have it log its parsed text to the console, however, it stops doing this when I do not talk for a minute or two.
Is there any way to fix this?
You can listen to the end event and then restart the recognition on the SpeechRecognition object.
You should use a boolean flag for deciding (in the onend event handler), when to restart the recognition (and when not to restart).
You could use the other recognition-related events for this.
E.g. Chrome triggers the following event handlers when recognition is started:
1. onstart
2. onaudiostart
(only if sound / speech is detected)
3. onsoundstart
4. onspeechstart
If no sound speech is detected, only the first 2 will be triggered, and then, after some timeout, the corresponding end events (in reverse order).
A simple solution for this could probably be to listen for the end event and restart the recognition
recognition.addEventListener('end', recognition.start);
recognition.addEventListener('end', () => recognition.start()) works but Chrome browser seems to obstrruct the continuity by generating a pop-up to Allow or Block the microphone every 5-7 seconds.

Object.observe remove in chrome 50

I had a warning message in Chrome, this one notice that Object.observe method is deprecated and will be removed in Chrome 50 around April 2016.
Have you an alternative solution to replace Object.observe ?
Thanks
So it was depricated and will be removed because of some problem with perfomance. Please see this link http://www.infoq.com/news/2015/11/object-observe-withdrawn
I think you should look into RxJS library and it's Observable
Using RxJS, you can represent multiple asynchronous data streams (that
come from diverse sources, e.g., stock quote, tweets, computer events,
web service requests, etc.), and subscribe to the event stream using
the Observer object. The Observable notifies the subscribed Observer
instance whenever an event occurs.
https://github.com/Reactive-Extensions/RxJS/

Windows 8 phone save state

I am quite new to windows 8 phone and I don't know all the life cycle methods and when what is called.
My problem is the following: I have a page that loads some data from the disk and when the user exits the program ( or suspends ) the data should be saved. As far as I can tell Page doesn't have an OnSuspending method only someOnNavigatingFrom, but those are not called when you just exit the program. So I read that I should use the OnSuspending in my App.xaml.cs, but this class doesn't have this data and also shouldn't have it, maybe only for OnSuspending. But I don't know how to get the data from my page in the OnSuspending method.
The OnSuspending event is quite fragile and you cannot expect it to run and save the state for a long time. But it depends on how long it would take for you to save. It doesn't even get triggered when you hit the home key while closing the app. If you really want an easy way. Just register a background task. While your app is in the background, the state can be saved and when you open the app again things are in place.
There are certain constraints With Background task as well, you cant do heavy lifting etc...here's a link you could use.
https://msdn.microsoft.com/en-us/library/windows/apps/xaml/hh977056.aspx
Implement an observer pattern (i.e. pub/sub) for your view-models to subscribe to in the event that your app is being suspended.
Your app handles the suspended event. As a result, publish a message for your view-models to respond to within your app's method handler for the suspended event.
You can use an EventAggregator or MessageBus (that I wrote).

gtkmm's answer to gdk_threads_enter() or SwingUtilities.invokeLater()

I am writing a gtkmm3 application and I need to create and show new GUI elements from a non-GUI thread. Specifically, I am trying to add a tab to a notebook.
I create the notebook in the gui thread like so:
Glib::RefPtr<Gtk::Application> app = Gtk::Application::create(argc, argv, "org.gtkmm.examples.base");
if(!Glib::thread_supported()) Glib::thread_init();
Gtk::Window window;
notebook = new Gtk::Notebook();
window.add(*notebook);
notebook -> show();
Worker bee;
bee.start();
return app->run(window);
and the I create and add a new tab like so:
Gtk::Label label("label");
Gtk::Label child("child");
notebook -> append_page(child, label);
notebook -> show_all();
If I insert the tab creation code before notebook->show() it works fine. But if I put the tab creation code into its own worker thread, the new tab never shows.
I'm guessing that the failure has to do with the fact that the new tab is created on the worker thread and that violates gtkmm's GUI stuff on the GUI thread convention.
The trouble is that the worker thread is responsible for creating new tabs, and I don't know how many tabs to create at compile time.
In APIs like Swing, and gtk+ there are mechanisms to handle this case. In Swing there is an invokeLater method that allows me to pass a lambda to the GUI thread for invokation, and gtk+ uses gdk_threads_enter/leave to ensure that only one thread is playing the GUI at once.
What is gtkmm's answer to this issue?
In general you should just avoid ever using GTK+ (or gtkmm) UI API from anything but the main thread. It's not meant to work.
You need to let the main thread respond when the other thread says that it should, instead of actually doing the UI work in the other thread. People like to use Glib::Dispatcher for this with gtkmm: https://developer.gnome.org/gtkmm-tutorial/stable/sec-using-glib-dispatcher.html.en .
But also think hard about whether you really need another thread at all. It might be fine to do the work in an idle handler: https://developer.gnome.org/gtkmm-tutorial/stable/sec-idle-functions.html.en