How do I see logs on parse-server? - parse-platform

Parse had a nice development command utility where you could read and stream logs.
Heroku has that, but it shows only Heroku logs, not Parse logs.
Is there some way to see a console.log or console.error statement now that we're all switching over to parse-server?

If you use PM2, it is really easy to see logs.
For my project, I have parse-server and parse-dashboard running on my server.
Here is the PM2 config I use for them:
{
"apps": [
{
"script": "parse-server",
"args": "config/server.json",
"log_file": "logs/server.log",
"error_file": "logs/server-error.log",
"log_date_format" : "YYYY-MM-DD HH:mm:ss Z",
"instances": 1,
"watch": true,
"ignore_watch": ["cloud", "logs"],
"env": {
"VERBOSE": "1"
}
},
{
"script": "parse-dashboard",
"args": "--config config/dashboard.json",
"log_file": "logs/dashboard.log",
"error_file": "logs/dashboard-error.log",
"log_date_format" : "YYYY-MM-DD HH:mm:ss Z",
"instances": 1,
"watch": true,
"ignore_watch": ["cloud", "logs"]
}
]
}
In my case, it is the "VERBOSE": "1" argument that allows me to see all the queries executed by parse-server.
If you want to see the logs of both parse-server and parse-dashboard, you then only have to type pm2 logs.
In my configuration, parse-server and parse-dashboard are installed globally (npm install -g parse-server and npm install -g parse-dashboard).

If you have Heroku CLI installed you can run these lines inside your project
heroku logs
for the last 100 lines or
heroku logs --tail
to show logs in real time

The latest versions of Parse dashboard have Logs page out of the box

I dont know about how you can see logs on Heroku, but i am able to see logs locally. What you need to do is when your run your application using command => node app.js then you will be able to see all console.log(""); statements in the console.
If you want you check this link . How to setup Parse on local machine.
https://www.webniraj.com/2016/01/31/parse-com-setting-up-the-open-source-parse-api-server/.
I hope this helps.Thanks

here are 2 ways, in case of selfhosted parse-server:
#1 view logs by url
create a symbolic link of your log-folder to /public/logs
add this middleware:
app.get(/^\/logs*/,(req,res,next) => {
if( req.url == '/logs/' || req.url == '/logs' )
return res.redirect('/logs/parse-server.info.'+new Date().toISOString().slice(0,10))
if( req.url.match(/parse-server\./) )
res.set('content-type','text/plain') // lets hint the browser for a logfile
next()
})
// *TODO* please run basic-auth middleware on /logs url
BOOM...now surfing to '/logs' will always redirect to the latest log-url.
You can just modify the dates to go back in time.
#2 view realtime logs
see this package https://www.npmjs.com/package/express-logio

You can use request.log.info() and request.log.error() and they will be show in the parse dashboard
Cloud Code function
Log on Parse dashboard

Related

Bad request when deploying smart contract

So I'm currently trying to deploy a router smart contract. I've been building it through erdpy contract build, which has been successful (I'm on rust nightly tool chain as the Smart contract needs it). And I am now trying to deploy it, but I can't manage to do it. I keep having a 400 BadRequest from https://devnet-api.elrond.com/transaction/send.
Here are the logs from the deployment:
erdpy contract deploy
INFO:accounts:Account.sync_nonce()
INFO:accounts:Account.sync_nonce() done: 0
INFO:cli.contracts:Contract address: erd1qqqqqqqqqqqqqpgqzqv7kk893c3ftwgaekvvv9whpqcfn4kazqxq3mud36
INFO:transactions:Transaction.send: nonce=0
CRITICAL:cli:Proxy request error for url [https://devnet-api.elrond.com/transaction/send]: {'statusCode': 400, 'message': 'Bad Request'}
And here is erdpy.json used to configure the command:
{
"configurations": {
"default": {
"proxy": "https://devnet-api.elrond.com",
"chainID": "D"
}
},
"contract":{
"deploy":{
"verbose": true,
"bytecode": "output/router.wasm",
"recall-nonce": true,
"nonce": 1,
"pem": "../../../wallets/owner/wallet-owner.pem",
"gas-limit": 600000000,
"send": true,
"outfile": "deploy-testnet.interaction.json"
}
}
}
The contract I'm trying to deploy is the following. I've also been through the OpenAPI Spec or the documentation searching for an answer, but there is nothing about it. This route is normally returning error message, but for this specific case it is not.
Some other contract like ping-pong are working properly with the same erdpy.json config.
After talking with someone who were interested into this issue, I ended up with the following command:
erdpy --verbose contract deploy --project=$PROJECT_NAME --pem="wallet-owner.pem" --gas-limit=600000000 --proxy="https://devnet-gateway.elrond.com" --outfile="elrond.workspace.json" --recall-nonce --send --chain="D"
Replace $PROJECT_NAME by the folder of your contract (you need to be one level upper than your smart contract folder).
It won't use the elrond.json file, but i guess you can move up the file to make the command use it.
I have you tried to deploy with the argument --verbose?
That should be something like that (not sure of the syntax because I am on phone)
erdpy --verbose contract deploy
I was getting the "bad request" error too, and I worked out that for me this was because my wallet was empty. To add xEGLD to your devnet wallet:
Go to https://devnet-wallet.elrond.com/faucet
Log in using your pem file / whatever you normally use to log in
Click the "Faucet" option from the left hand menu
This should pop up a modal to add 10 xEGLD to your wallet (You can request 10 xEGLD every 24 hours)
Now you can return to the terminal and run erdpy contract deploy
This worked for me, and now I'm getting the correct output.
In the suggested erdpy.json from Elrond Docs there is an "chainID": "D" variable inside configuration.default object.
Delete this and add inside contract.deploy this : "chain": "D".
Example
{
"configurations": {
"default": {
"proxy": "https://devnet-api.elrond.com"
"chainID": "D" <----- Delete this
}
},
"contract":{
"deploy":{
<Other fields>
"chain": "D" <----- Add this
}
}
}

console.log is not displayed in heroku logs

I have the program heroku_test.ts
console.log('test')
I can run it with the following command:
heroku run ts-node heroku_test.ts
In the same console window I see it output 'test'
But when I look at heroku logs, there is no 'test' there, it just says "Starting process with command ts-node heroku_test.ts"
Why heroku logs do not contain console.log output?
EDIT: the question is different from how to show all console.log from node.js in heroku? because I can see all the logs except any console.log output.
First install winston :
https://github.com/winstonjs/winston
as follows :
npm install winston --save
Then change your heroku_test.js to the following :
const winston = require('winston')
winston.log('info', '-------Hello log files!------------', {
someKey: 'some-value'
})
Then run
heroku run node heroku_test.js
Then check the logs :
heroku logs --tail
and you should see the above in the heroku logs
you can try some opensource libs, e.g.,
https://www.npmjs.com/package/heroku-logger

Heroku release phase bundle not found

I have the following release phase in my Procfile:
release: bundle exec rake db:migrate
It works great when I merge PR's into my staging and production apps, but it fails when running on a new review app. The Heroku docs say that the release phase is run after a successful build, so I don't know why it can't find bundle.
This is my output
heroku releases:output 9 --app my-app-pr-253
/bin/sh: 1: bundle: not found
For Heroku's review apps, you must specify all buildpacks and ENV vars you need in the app.json file. You can either manually create one, or have Heroku generate one for you.
https://devcenter.heroku.com/articles/github-integration-review-apps#app-json
Confirm that in your app.json you have specified
1) The required buildpacks https://devcenter.heroku.com/changelog-items/670. Since you are using bundle I'm guessing heroku/ruby will be one. Below is an example.
"buildpacks": [
{
"url": "https://github.com/heroku/heroku-buildpack-ruby.git"
},
2) Also make sure you specify any config variables that you want to inherit from the app off which your review app is being built. https://devcenter.heroku.com/articles/app-json-schema#env Missing one of these could also be causing a build to fail.
If neither of these work, try checking the logs for your heroku app. Watch the ones in the Heroku GUI during the build. Also try to tail the logs in the CLI.
heroku logs -t -a <review_app_name>
I figured out my problem. It was a silly typo:
"buildpacks": [
{
"url": "heroku/ruby",
"url": "https://github.com/guillaume-tgl/heroku-buildpack-ghostscript.git"
}
]
should have been:
"buildpacks": [
{ "url": "heroku/ruby"},
{ "url": "https://github.com/guillaume-tgl/heroku-buildpack-ghostscript.git" }
]

Configuring the Hyperledger Composer REST server with a persistent data store

I am following this tutorial
https://hyperledger.github.io/composer/integrating/deploying-the-rest-server.html
I have done all the steps. But when I run rest-server through github, it prints following stack trace.
Error
404 Cannot GET /auth/github
status: 404
Error: Cannot GET /auth/github
at raiseUrlNotFoundError (/home/praval/.nvm/versions/node/v6.11.1/lib/node_modules/composer-rest-server/node_modules/loopback/server/middleware/url-not-found.js:21:17)
I presume you installed the Github strategy via npm install -g passport-github?
If so did it create a folder /auth/github?
You are required to go to this Folder per documentation: "Authenticate to the REST server by navigating to the value of the authPath property specified in the environment variable COMPOSER_PROVIDERS. In the example above, this is http://localhost:3000/auth/github"
In my case that folder was not created. I read on Github website: https://github.com/cfsghost/passport-github
"The author of Passport-Github has not maintained the original module for a long time. Features in his module don't work since Github upgraded their API to version 3.0. We forked it and re-published it to NPM with a new name passport-github2"
I'm looking for guidance on this.
Before create private api just execute this command in your terminal.
export COMPOSER_PROVIDERS='{
"github": {
"provider": "github",
"module": "passport-github",
"clientID": "<your id>",
"clientSecret": "<your secret>",
"authPath": "/auth/github",
"callbackURL": "/auth/github/callback",
"successRedirect": "http://localhost(domain of angular app):4200(port)/home(page to redirect)",
"failureRedirect": "http://localhost(domain of angular app):4200(port)/login-github(page to redirect)""
}
}'
To check if all is fine - run command
echo $COMPOSER_PROVIDERS
After this you will see your COMPOSER_PROVIDERS value.
And after in github profile app (https://github.com/settings/applications/) you must configure "Homepage URL" (ex. http://APIdomain:3000/) and "Authorization callback URL" (ex. http://APIdomain:3000/auth/github/callback)

Server not available on Parse Server Dashboard

I've setup Parse Server Dashboard on my local machine, and followed the instructions to connect to my Parse Server which is hosted on Heroku.
The Server URL I use to connect to Heroku in my iOS is:
https://my-app-name.herokuapp.com/parse
, so I used this for the Dashboard also.
My config settings are:
{
"apps": [
{
"serverURL": "https://my-app-name.herokuapp.com/parse",
"appId": "appId",
"masterKey": "masterKey",
"appName": "appName"
}
]
}
, however I am getting the error "Server not reachable. Could not connect to server".
When I remove the https://, I get the error "Server not reachable. Server version too low."
The version is 2.1.4, which is the minimum requirement for the Dashboard.
Any suggestions please?
Thanks!
Make sure the config vars (APP_ID, MASTER_KEY, SERVER_URL) between your Parse server and dashboard are set identically. Use https:// instead of http:// for both SERVER_URLs.
To verify your config vars are the same:
Go to your Heroku dashboard
Open both your Parse Server and Dashboard in new tabs
Go to each respective setting tab
Click the Reveal Config Vars button under Config Vars and verify that APP_ID, MASTER_KEY, SERVER_URL are identical for both apps.
Try following these two steps:
npm install -g parse-dashboard
Then
parse-dashboard --appId yourAppId --masterKey yourMasterKey --serverURL "https://example.com/parse" --appName optionalName
The URL should not contain double quotation marks

Resources