I've given the docs a good looking over as well as SO, however can't seem to find any answers.
I have a packaged chrome app (new style, not legacy)
I can find many documents on enabling logging as in errors/crash reports, but can't find anything about custom logging. For example:
On initial load some 3rd party data is loaded via a api call, lets just assume it:
$http.get('/api/get-my-data').onSuccess(function(data){
// Yay, I gotz the dataz. Do something
}).onFail(function(error) {
// Damn son, something went wrong.
});
In the above pseudo code I'd like add to a chrome error/custom log to record the onFail condition. I'm not looking to record error in the sense that the app has crashed or a fatal error, I'm looking to log events that in the context of the app running correctly I regard as errors.
If an error caused the app to crash etc then I'd get a entry in the chrome logs, but there must (I assume) be away to log data directly to a log on the server that isn't considered an error (perfectly common if this was a web app on a server (log4j, KLogger, Morgan)) but I can't find it
Anyone else created a chrome packaged add and used the inbuilt logging?
Thanks
N.B. Just to be clear, we are talking about logging in a packaged app with javascript to a log file, not console.log
Thought I'd answer this incase someone else comes across it as it's not clear form the google docs.
when you use console.log it gets sent to your strdout/chrome log file.
You have to enable logging in your chrome app launch config/flags, then any console.log in your code will show up where ever you set your user-dir to be.
It's not clear from the documentation, but basically your chrome app will automatically log and console.log you have
This includes other console methods.
Related
I'm in the process of learning Javascript. I installed the Live Server extension on VS Code, as well as typing "live-server" into the terminal, to see Chrome's console update upon save. Whenever I have a live server up, I keep getting this message in red in the console:
VM4057 content_script.js:1 Uncaught SyntaxError: Identifier 'WBSAutoFillFormTypeUndetermined' has already been declared (at VM4057 content_script.js:1:1)
The only thing I have at 1:1 is 'use strict';, but even if I remove that I still get the message. All code works otherwise. Is there something I can change to make it stop? And just to be clear, I use either the extension or type live-server. Never both at the same time.
The error comes from the Apple's chrome plugin "iCloud Passwords". Deactivate or remove it and the error will disappear.
I'm trying to implement the onEdit(e) simple trigger of Google Sheets. Everytime I try execute even a simple function such as:
function onEdit(e){
Logger.log(e.oldValue);
}
I get the following error:
My step by step:
I've tried following these two videos with no success:
https://www.youtube.com/watch?v=eWn_JxPSbds
https://www.youtube.com/watch?v=L1_nIhiVc5M
EDIT: SOLUTION
Thanks to #JPV and #TheMaster for the two potential solutions:
I was viewing the "Logs" and not the "Stackdriver Logging".
It seems you need to disable the V8 to view it in Logs, but need the Stackdriver Logging to view it with V8.
At least that seems to be the case with me
EDIT TWO
Here's the documentation where the issue is addressed:
https://developers.google.com/apps-script/guides/v8-runtime#ui_changes_for_logging
"If your script uses the Rhino runtime, selecting View > Logs in the Apps Script editor only shows you recent logs written by the Logger service. You must select View > Stackdriver Logging to see logs written with the console class."
Nothing is wrong with V8. That error is because you ran the script directly by clicking run button before. That caused the error and was logged. When you edit, it is logged to view>stackdriver logging. But the previous error is shown to you. You're looking at old logs.
As per the official documentation,
For scripts using the V8 runtime, the script editor View > Logs menu item shows both Logger and console results for the most recent execution in the current session
Only current session logs is available to View>Logs. To access previous session logs or logs logged not by running a function directly in the current session, use View > Stackdriver Logging
....
This seems to be a glitch in the new V8 engine. Disabling V8 should fix it. Let's hope this will be fixed soon.
Very simply, I would like to disable the display of the repeated workbox messages that appear in my browser console while I am debugging. For instance, I don't need to see:
WorkBox: Using NetworkFirst to respond to '/fonts/KFOlCnqEu92Fr1MmEU9fBBc-.woff'
It clutters my FireFox console and it is something I dislike very much. If you like it, fine, please don't try to change my mind about the benefit of such useless (to me) messages.
Do you know how to turn it off?
For info sake, I am using Quasar and Vue to create a SPA - not even a PWA.
Thanks.
Simply add self.__WB_DISABLE_DEV_LOGS = true at the top of your service worker (sw.js) file.
Contrarily to what answers posted here say, the solution is not:
to unregister your service worker to get rid of the messages. Your app may need it to run properly
to add workbox.setConfig({debug: false}) unless knowing what it does:
it switches between a production build and a debug build. workbox automatically selects the debug build when running on localhost.
For me worked:
Console -> Application tab -> Service workers -> sw.js unregister
You can use workbox.setConfig({ debug: false }); in order to use production build and remove extra logging, otherwise adjust your web console log level filtering accordingly.
Doc : https://developers.google.com/web/tools/workbox/guides/troubleshoot-and-debug
You add this setting in your service worker definition file, after the import. For example:
importScripts(`https://storage.googleapis.com/workbox-cdn/releases/4.3.1/workbox-sw.js`);
if (workbox) {
console.log(`Yay! Workbox is loaded 😁`);
} else {
console.log(`Boo! Workbox didn't load 😬`);
}
// Switch debug logging on/off here. Default is on in dev and off in prod.
workbox.setConfig({debug: false});
For more information on this see https://developers.google.com/web/tools/workbox/guides/configure-workbox#configure_debug_builds_vs_production_builds
Thanks to the answer provided by Antonina K, I was able to locate an answer for FireFox. In case anyone else needs this. As Antonina mentioned, in Chrome, the console has an application tab that has references to all the service workers used by the browser. FireFox does not have the tab (or, at least my version does not).
In FireFox, open a new tab and place about:serviceworkers in the address bar. Scroll through the list to find the workbox service worker. For me, it was listed as localhost:8080. I deregistered that worker and I no longer see the multitude of workbox messages in my console. I can finally debug my app again!
Here is the link that I referenced to fix the problem:
Manage Service Workers in FireFox and Chrome
When I try to log into app, the error I get in client console (chrome dev tools) is this:
Uncaught Error: Expected to find a document already present for removed mongo.js?69942a86515ec397dfd8cbb0a151a0eefdd9560d:253
and the login is halted: the loading gif from the accounts-google package shows and the loading never ends.
I however get no errors in server console. Unfortunately, the error gives me little understanding as to where to even start debugging my app from.
I have gone through the portion where the error is thrown in the mongo.js file, but I don't get what's going on there from it either.
Since I do not have any idea where I am going wrong, this is the link to the project repository.
Maybe you was use fast-render package and doing 2 subscriptions for the same publication as explined here
Hope this help someone.
The main idea is to run a random page on Internet Explorer and get javascript errors and logs.
Is there a way to recover javascript console logs and execution error
from a random web page without accessing the F12 tool on Internet
Explorer?
I found that with Chrome based browser, you can get it on your AppData file log by adding --enable-logging --v=1 args when launching.
Any solution with any language are welcome.
Thank you for your answer.
NOTE :
random page on Internet Explorer means that I do not have the access on the source code.
Basic solution to this would be:
1. Use Exception Handling to catch the errors.
2. Log errors in a Global Array
3. Log the errors in a file using Blob and URL.createObjectURL. All recent browsers support this.
Have you considered using a Bookmarklet that:
Overrides window.console.log and window.console.error (to intercept messages)
Logs incoming messages somewhere using createObjectURL?
Or you could use something like firebuglite and auto-enable it like this:
<script type="text/javascript" src="https://getfirebug.com/firebug-lite.js">
{
overrideConsole: false,
startInNewWindow: true,
startOpened: true,
enableTrace: true
}
</script>
More instructions are here: http://getfirebug.com/firebuglite
If the F12 tool is not of your interest, then what about the Event Viewer? Open Event Viewer from Control Panel -> System and Security -> Administrative Tools -> Event Viewer. Then select the log Applications and Services Logs\Internet Explorer.
By default no events are being logged for Internet Explorer, to enable them create a new DWORD registry value named Feature_Enable_Compat_Logging under the following registry key:
HKCU\SOFTWARE\Microsoft\Windows\Internet Explorer\Main \FeatureControl
and set the registry value to 1.
Check the logs you get to see if it's what you're looking for.
One idea would be to write a browser extension which listens for window.onerror and writes to a file. Definitely not as elegant as the Chrome solution, but it would work fairly well.
Using local proxy might be a good one-time solution.
Charles web debugging proxy app has nice UI and it allows to replace any response with local resource.
So basically you'll need:
Download one any of the js files used on target page
add any code you wish to saved version
set up Charles to serve you your local version instead of remote one
You might try Fiddler. It's got its own logging and has amazing inspection power. It won't capture IE specific errors, since it's at a different layer, but it will definitely get you any code that's coming over the wire.