How to read console.log on the terminal using parse.com - javascript

I am new using cloud code of parse.com
I am trying to debug my cloud code, but I can not read the console.log in the terminal. I am using the console of my Mac in this way:
parse deploy
Once the code has update successfully, I curl -X POST the code of the app (the function I want to test) but I can only read the response.success() or the response.error(), all the console.log that I have in the code doesn't appear in the console.
I assume that the log output should appear in the console, but it doesn't.

note for anyone reading, Parse.com is closing down later in 2016 - so don't get too invested in it :O
consider say back4app.com
If you're reading this in the far future .. Parse.com was an ingenious BAAS which ran for a couple years, sensibly sold out to Facebook, and then FB gave up after a couple years. It was basically free to use, so the whole fiasco maybe marks the end of the "amazing stuff, totally free to developers" era.
In your Terminal it's
] parse logs
to see the last few logs.
or if you want to watch everything continuously from the cloud,
they have a command which pipes that output continuously to your terminal:
] parse develop "Your App Name"
So as you, or indeed normal users of your app, uses the Parse app, you can watch "everything that is happening".
(Note too that, once you "turn on" the "parse develop" mode: as well as printing out everything that is happening on the server, additionally: if you locally edit the text files (main.js and so on) in fact, it goes ahead and uploads them to the server, that is to say, just as if you had done a "parse deploy".)
This is a good question -- it's really quite astounding that this is so badly explained everywhere, since, Parse is completely unusable unless you know about these two commands!!

Related

Where to find EJS-Lint output, and what should it look like?

I use EJS in my projects, and as it goes, I run into 500 errors every time some aspect of the EJS doesn't load properly--be it that a res.locals variable didn't get passed in, or a file path is wrong in a render() method.
All I receive is a 500 error. No messages, no line numbers, no error type, nothing.
Here is the terminal output when the page doesn't load:
And here's what the browser shows:
On other projects using a different kind of error display page, I've seen some error messages that say "If this isn't helpful, try EJS Lint", so I installed it and look into the "documentation", such as it is, and It has zero information about what to expect from output. I paste in the commands and the path to the file I need to test, and the CLI just sits there, and the API seems to do absolutely nothing.
Here's what I've tried in the CLI:
ejslint /views/owner/dashboard.ejs
And for the API call:
const ejsLint = require('ejs-lint');
ejsLint('../views/partials/addUserForm.ejs', {states, datePoints, beginDate, endDate, recentCompanies, allLocations, recentInvitations, recentForms,totalQuestions, totalCompanies, totalForms, graphDatasets, page:'ownerDashboard'});
Again, no messages. No errors. No output of any sort, at all.
Is there a resource somewhere that explains, step-by-step how to use this tool?
This answer is the closest I could find, and it still says nothing about where any output will show, what it will look like, how it will be formatted, etc: how to use ejs lint in cli

Tomcat websocket code succeeds on localhost but fails when hosted and modified for remote host

This has been discussed before, but never successfully (as far as I can tell) resolved. I'm using Tomcat 9, eclipse, and of course Java and Javascript.
Chapter 1
I can make work neither the well-written javaCodeGeeks websocket example, or for the purposes of providing a minimal framework, re-hosting the Tomcat example chat/echo code outside of their magic realm. (I'll have more to say about this below.)
I've also been poring over the Tomcat logs and scrutinizing the GET requests which return 404 errors and mystery 7xx error codes, some of which I've been able to infer. (There is no general documentation of the 7xx codes.) I'll discuss those at the bottom.
So the nub of the issue is that Websocket code works end-to-end when hosted by Tomcat on localhost, but when hosted on a remote host, the connection created by "new WebSocket" fails. (This issue has been discussed several times, in multiple forums, but it seems more likely that the questioners have given up rather than succeeded and moved on.)
So I would like to know two things. First, how to make my example code work when hosted remotely (any port in a storm) and second, I would like to know how the tomcat examples work at all. The sample I've concocted is not something new and suspect; it is simply the chat annotation from the Tomcat examples. (There are a few reductions so that it works in a minimal environment, and those are noted. In particular the logging routines, and a parse-html class was pulled from its home on Tomcat.)
The result of this sample when executed against a remote server is a 404 error (with some curious 7xx error codes, which I observe and report on below).
If you want to cut to the code, here is a link to a war file that includes sources; They are just adopted from the Tomcat sample chat server to run in a minimum configuration. Three files, 2 java and one index.html. You can run/deploy it directly on tomcat in webapps or pull the sources into eclipse to compare and edit.
SampleCode
Dossier
https://1drv.ms/u/s!AqbqlA2vzkjRcrGjW8rDRLW3o50?e=fgeh0U
Here is the point:
var target;
// Shows the bug: unless location resolves to local host won't work
target = 'ws://' + window.location.host +
'/SocketBugMinimum/websocket/chat';
//
// For testing purposes,
// access the tomcat one in the magic directory, not this one...
//target = 'ws://' + window.location.host +
// '/examples/websocket/chat';
// also try:
// examples/websocket/echoStreamAnnotation
// it will work too...
And when it goes behind the curtain
Chat.socket = new WebSocket(target);
it returns with the error on the console:
WebSocket connection to ws:REMOTEHOST:8080/SocketBugMinimum/websocket/chat failed: Error during WebSocket handshake: Unexpected response code: 404
Now a couple of things to note.
1. Works fine when host is localhost.
2. You can connect to remote host accessing the Tomcat examples websocket, even though they have nothing to do with this code. This is both fun and instructive.
3. This works even when you are yourself hosted on localhost.
The SocketBugMinimun app produces the same result run from eclipse, accessing localhost or remotehost from either chrome or firefox, and from the tomcat html-manager (i.e. host...8080:/Manager/html).
Now looking through the Tomcat logfile (grep the ones with today's date for GET to see all the connect activity) you will find an interesting numeric code beside the reported 404 error.
As I promised above, I've tried to infer meanings of some of the 7xx codes produced in the logfile; they seem to modify the 404 error. (7xx codes are not part of HTTP as reported in an RFC; they seem to be recycled and augmented Modem codes, of all things.) If anyone has a better understanding, please share it. Tomcat-developer endorsed description of these codes it would be great to know. apparently tomcat websockets busily produce different and rich errors, but there is just no way to know what they are. (I've scoured the tomcat docs, and Google finds nothing.) In order of usefulness:
727 Listener exists but terminal endpoint is bad
733 Endpoint exists and is hunky dory but I won't let you connect to it because I'm mean
719 No root element
746 Valid root, but the rest of the path is bad
726 You tried /a/b but you need /a/b/c
737 Beats me
748 No idea
Chapter 2
Now the mystery to me is how the Tomcat examples work at all.
It appears that by being hosted in the examples directly they seem to have conferred on them some magical powers to use sockets. I've tried to reproduce those results using catalina privileges but am unsuccessful. (And if you are a connoisseur of Tomcat privileges you will note that the sample files says "this is what you should do to generate these effects" but those lines are COMMENTED OUT and the examples work anyway!)
I also experimented with Valves, but have nothing useful to report. If it wouldn't kill the Tomcat people to provide a few more documented examples, it would be helpful.
There is also a voodoo file in Tomcat called servers.json (you will note that no other files with a .json extension are shipped with the product). This file and its curious and undocument incantations change the names of the network pathname to the endpoints. (This file is why I chose to repro this with chat, which uses no other magic, rather than echo.)
One likely solution might be that the examples are conferred special powers in catalina.policy. But no dice. I tried to add WebSocket privs, and it doesn't do any good. Here is the diff between the original and what I added.
// ++
< // everyone needs sockets!
< grant {
< permission java.net.SocketPermission "*:8080", "accept,connect,listen,resolve";
< };
<
< // Granting permission for Spades to be reached via websocket
< grant codeBase "war:file:${catalina.base}/webapps/Spades.war*/-" {
< permission java.net.SocketPermission "*:8080", "accept,connect,listen,resolve";
< permission java.lang.RuntimePermission "accessClassInPackage.org.apache.tomcat.websocket";
< permission java.lang.RuntimePermission "accessClassInPackage.org.apache.tomcat.websocket.server";
< permission java.sercurity.AllPermission;
< };
< //--
<
275c260
< // };
As I said, it didn't seem to do any good. Same sad errors in the logfiles.
Thanks in advance for your help.
Marklan
Problem solved.
I did some more snooping around and learned that there are discrepancies in Tomcat results when you are running older versions of Java. Coderanch had this helpful article:
https://coderanch.com/t/659638/application-servers/WebSocket-deploying-Server
I checked and realized I had Java 1.8 on my server. (Dooh!)
Thanks to ServerWorld for its helpful site, here is helpful information on upgrading Java, finding the version you need, etc. Here is a link to the English version, from there you can select OS config, etc.
https://www.server-world.info/en/
So, I upgraded to version 11 JDK (i.e. downloading jdk-11.0.1_linux-x64_bin.rpm from oracle.com) running rpm to install, i.e. from the download directory
rpm -Uvh jdk-11*
to install.
Finally configuring away from the old version without deleting it (in case this doesn't work!)
alternatives --config java
to select and install the latest. Restarted Tomcat and it all worked.
Thanks to the people who looked at this with me, and scratched their heads. I appreciated the efforts.
Happy coding. Hopefully this mis-adventure can be helpful to anyone else who has the same problem.
And it would sure be nice if the Tomcat team could document the 7xx errors. I have no idea why the older versions of Java did not work. I can't imagine how something like this would be version dependent, but I guess my imagination is just not that good...
I did find some other useful stuff that I want to share. In particular the magic cookie that makes the examples files work is buried in a call to ServerApplicationConfig, wheich essentially exports and deploys the endpoints in subdirectories. Check out the file ExamplesConfig.java buried off in webapps/WEB-INF/classes/websocket. It takes advantage of a Tomcat hook that scans your subdirectories for you, and exports endpoints, or declines to export them as you wish.
M

In chrome console how to copy the last 20 commands i have written to clipboard

Is there a way to copy all the commands i have written, or to give it some range. Or at least print them out together so i can copy them.
I was trying out jquery selectors in console, after half hour of dealing with very messy dom structure i finally got what i wanted now to transfer that i have to back in history and copy paste every single command. It'd be nice if could log all i have writen, or like last 30 commands etc.
I think it should be possible, as i have seen pretty other advanced abilities of chrome console.
This answer appears to address your question.
Enable logging from the command line using the flags:
--enable-logging --v=1
This logs everything Chrome does internally, but it also logs all the
console.log() messages as well. The log file is called
chrome_debug.log and is located in the User Data Directory.
Filter the log file you get for lines with 'CONSOLE(\d+)'.
via Save the console.log in Chrome to a file
More here on logging. The Chromium Projects: How to enable logging

Can't retrieve a valid WinSAT assessment. javascript console

i frequently get this error when running my web app on google chrome
[2536:2008:0502/143602:ERROR:gpu_info_collector_win.cc(96)] Can't retrieve a valid WinSAT assessment.
its ok in firefox and IE..
i've already search for solutions but with no luck.
i am using Aptana Studio + Sencha
how to get rid of this?
I had this error when I was providing the path to chrome.exe as the system property - it went away when I was using chromedriver.exe as downloaded from here: https://code.google.com/p/chromedriver/downloads/list
This means that winsat validation failed.
Winsat is a tool that checks out windows. If it fails, normally this indicates that something is wrong with your system (probably a driver).
In the above case, I would go with the display adapter driver, so try to update it via the Windows Update.
To run winsat yourself, you can run 'winsat formal' from the command line. Then you can look for suspicious output (if you have 0 F/S performance in the direct3d, then this is not fine :-))
Based on the problematic output, you can see what is wrong in the system (in the above example, the display adapter was found as a standard VGA, and a simple update, fixed the error made chrome/selenium).
HTH

Getting data from the browser's console using javascript

I don't know if this has been asked before, but what i'd like to be able to do is get data from the error console within the browser itself(if it supports it) this would be for when a user sends off a bug report it'd pull up any errors related to pages at my website for things such as typos in code and other things that somehow managed to slip by. Also, in that regard is there a way to pass the errors from the console to a useable format? If this isn't possible, then i could just tell them to copy and paste what came up from the site itself.
I thought of this right now as i was thinking about how to make the bug reporting system run better since the entire thing is basically ran within the browser and for the backend I can easily just look at error logs but for the frontend ie javascript bits of things it's not goign to be as easy.
So to finish wrap all of this up in one little statement, is there an easy way to get the data from the error console and be able to send it along via javascript ie to a form, or something similar.
You can use the onerror event in JS to get the details of the error. Hoptoad do this for example and log the errors to their console, Their code re-uses lots of nice JS scripts including a printStackTrace function that is great.....
You can see how they do it here:
http://hoptoadapp.com/javascripts/notifier.js

Categories