FAQ Database Discussion Community


Logging nodejs application in production

node.js,logging,error-logging,console.log
I am a newbiee to node. can anyone tell how to handle errors in nodejs. Also how to define node server to write its logs to a default file instead writing to console. Thanks in advance Regards VHC...

Content-Security-Policy breaking console.log output

javascript,cordova,console.log,content-security-policy
Developing an app on version 5 of cordova (using the phonegap framework). The latest updates request you use a Content-Security-Policy meta tag as per their documentation: https://github.com/apache/cordova-plugin-whitelist Here's my tag for the app: <meta http-equiv="Content-Security-Policy" content="default-src *; style-src 'self' 'unsafe-inline'; script-src 'self' 'unsafe-inline' 'unsafe-eval' *.example.com"> When I include this everything...

Node.js OpsWorks Layer console logs

node.js,console.log,aws-opsworks,monit
I have an Opsworks stack with a Node.js Layer and Node.js Application. I'm wondering if anyone knows where on an ubuntu 14.04LTS instance the console logs from my application are being printed to. I know the opsworks uses monit to run my application but i'm not sure where its outputting...

Why event.target gives multiple results?

javascript,jquery,console.log
I have a 3*3 table. When I click on td element in my console log td is printed six times and I want it to print out just once. Why is this happening and how to prevent it? JS: $("*").click(function(event){ console.log(event.target);//is this here executing 6 times, why... }); HTML: <table>...

mOxie is undefined, yet very clearly defined

javascript,internet-explorer,console.log
I'm pulling my hair out over IE9/8; I'm trying to use mOxie, but it's showing up as undefined, even though it's very clearly defined. when, from another file, I log mOxie to the console, it logs it perfectly fine in Chrome/IE10+, but firing the same script in IE9/8 logs undefined....

$0-$4 not recording last selected DOM elements in Chrome console

javascript,google-chrome,debugging,console.log
I've read on the Chrome command line API that I can use $0-4 within the terminal to get the most recently selected DOM objects. However, I cannot get it to work as I expect. $("#ev"); [<button type=​"button" id=​"ev">​Event attached to this button​</button>​] console.log($0) //<body></body> It looks like an array is...

How do I redirect asynchronous output to a file?

javascript,node.js,asynchronous,console.log
I have a Node.js script that reads the contents of a file, does some transformations on its contents, and logs the output: var transformer = require('./transformer'), fs = require('fs'), file = process.argv[2]; if (!file) { throw 'no file specified\n'; } fs.readFile(file, 'utf-8', function (err, data) { if (err) { throw...

Console.log javascript not working in web browser

javascript,console.log
I am trying to use console log to log the date in the console log but it is not working. Here is my code: setInterval(function(){ console.log(new Date()); },1000); As you see this code is simple and should run because no syntax errors that are there. But when i use Firefox...

How to console.log large object? [duplicate]

javascript,node.js,object,console.log
This question already has an answer here: How can I get the full object in node.js console.log, rather than '[Object]'? 5 answers I'm trying to see what the object contains With console.log(obj) the console cuts off from the lines and I can't see the entire structure. Then I tried...

How require() works in JavaScript and how its usage affects console.log?

javascript,node.js,require,console.log
Could someone explain how require() and console.log work in javascript? I have a code snipped saying something close to this one: var somevar = require('C:/Users/Me/Folder/SomeFolder/somefile.js'); console.log(somevar); In the console I see the following: { _maxListeners: 0, reset: [Function], verify: [Function], report: [Function], getSource: [Function], getSourceLines: [Function], getAllComments: [Function], getComments: [Function],...

javascript console letters A and j appeared for Objects, what do they mean

javascript,extjs,console,console.log
In javascript code, once you use console.log() , in the browser console (google chrome), some letters appear before or after an Object description ; letters like A and j. What do these letters mean? ...

ipython %%javascript magic output into cell and console

javascript,ipython-notebook,console.log
How to adjust ipythons' %%javascript cell magic so that it outputs both to output cell of ipython and to console of the browser as shown below I don't want to use alert(). Furthermore, I tried to get similar behavior with nodejs using %%script magic %%script node console.log("Hi") But this is...

Form.onsubmit not working

javascript,internet-explorer-9,console.log
I'm creating a script to check something in my code. This script runs successfully on Chrome, but it doesn't run on IE. This is run on onsubmit in my form <form id="frm1" name="frm1" method="post" onsubmit="return checkForm();" action="save_dept_add.php"> And this is my script (I've put it in head tag) <script language="javascript"...

How to show all console messages on a div?

javascript,console.log
I have this code: if (typeof console != "undefined") if (typeof console.log != 'undefined') console.olog = console.log; else console.olog = function() {}; console.log = function(message) { console.olog(message); $('#debugDiv').append('<p>' + message + '</p>'); }; console.error = console.debug = console.info = console.log Which works great for simple console logs, but i want...

Eloquent JS example doesn't run anywhere but the EJ sandbox

javascript,methods,console.log
I just opened up Eloquent JS to sharpen up my JavaScript skills. In the very beginning of the book Haverbeke shows a program written in binary meant to add up the numbers between 1 and 10 and spit out the total. He then simplifies the program from binary to 1...

Console.log a multi-dimensional array

javascript,arrays,multidimensional-array,console,console.log
So I have created a multi-dimensional array: (i.e. one with two sets of 'coordinates') var items = [[1,2],[3,4],[5,6]]; My site is in development and the array, when it is loaded, and what it contains is constantly changing, so I need to be able to, whilst running the script, dynamically view...

Javascript structure to provide varying levels of debugging code with ease

javascript,console.log
My [research] program is growing quite large, like many projects. I also battle the fight between getting work done and teaching. I would like to have different amounts of console.log() statements with just changing something like a global variable or similar. This is similar to typing --v (or similar for...

How to properly use if else and else if

javascript,function,random,console.log
I am using codecademy courses and I'm learning how to make a rock paper scissors game out of randomizing numbers. It says I've done a "good job" but every time I try to properly get each one to properly show up to their respective conditions it messes up. Please leave...

for loop to print out multiple arrays with similar names

javascript,arrays,loops,for-loop,console.log
I've got multiple arrays, like so: bugNames0 = ["wasp", "roach", "stinkbug", "mantis"]; bugNames1 = ["hornet", "beetle", "ant", "termite"]; bugNames2 = ["gnat", "fly", "grub", "chigger"]; bugNames3 = ["flea", "bed-bug","maggots", "cricket"]; Next up I have this for loop: function bugLoop() { for (var i=0; i < 4 ; i++){ console.log(bugNames0[i]); } }...

Why would a return be undefined but console.log return an int?

javascript,recursion,console.log
So I have the following function: var multiplyT = function(a, b, acc) { if (b == 0) { console.log("BASE CASE: ", acc); return acc; } else { b--; acc = acc + a; console.log("NOT THE BASE CASE: ", a,b,acc); multiplyT(a, b, acc); } } It gets called with: console.log(multiplyT(5,3,0)); And...

D3 Elastic easing transition of circle radius causes negative radius to be set

javascript,d3.js,console.log,easing,easing-functions
I have a very weird problem whilst using the ease("elastic", a, p) function in d3js. I am transitioning the radius of circles and I'm getting a flood of errors in the console, which are significantly slowing down my webpage. The errors state that I'm setting a negative radius — after...

How to console.log an object definition and a text in same string?

javascript,object,concatenation,console.log
I have this JavaScript code: console.log(obj);// [query: "wordOfTheDay"] console.log(note + " : " + obj ); // obj does not show up I want to make "obj" display in the same string as "note" no matter the type it come in as. For example: console.log("text sample : " + obj...

Suppress “Failed to load resource: net::ERR_FILE_NOT_FOUND” in Chrome Packaged App

google-chrome,webview,google-chrome-app,console.log
I get the message "Failed to load resource: net::ERR_FILE_NOT_FOUND" in the console when a webview in a Chrome Packaged App tries to load a non-existent local file. This is expected, because the program is supposed to check a couple of different location, starting with the local system and then switching...

Why console.log displays incorrect object's values?

javascript,google-chrome,console.log
I don't understand why console.log displays that d1 contains [100,200,300] before I even introduced these numbers. Regular for loop displays internals of d1 correctly though. Can someone please explain this behavior/bug of console.log in Google Chrome? https://jsfiddle.net/ZSvyt/ var container = {}; container["0"] = [10, 20, 30]; var d1 = container;...

node.js child_process.spawn output to console odd format

node.js,console,console.log
I'm trying to write a small wrapper to execute a shell command via nodejs and print the output of the command to the console. so far I'm pretty much done, but the format of the output in the console is... awkward and and I have no idea why. :( #!/usr/bin/env...

Is there a way to output HTML within Firebug's console?

html,firebug,xdebug,console.log,var-dump
I'm using Firebug's console.log() to output Xdebug's var_dump() result and it looks like this: <pre class='xdebug-var-dump' dir='ltr'> <b>array</b> <i>(size=1)</i> 'offset' <font color='#888a85'>=&gt;</font> <small>string</small> <font color='#cc0000'>'40'</font> <i>(length=2)</i> </pre> Is there some way to output it as processed HTML without using the HTML tab within the Net panel?...

Why javascript console.log(1 + + “ ” + 3); sentence returns 4 and not “1 3”?

javascript,console.log,coercion
When the statement console.log(1 + + " " + 3); is executed in the Chrome console, the result is 4 and not "1 3" as i would expect. Can someone please explain why this is the case?...

Why does console.log() output an unexpected 0 in my code? [closed]

javascript,console.log
So here is my really simple code in JavaScript: var chessBoard = function (size) { for (var i = 0; i<size; i++) { var line = ""; if (i%2 == 0) line =+ " "; for (var j = 0; j<size; j++) { if (j%2 == 0) line += "...

View a Javascript method's contents in Chrome console

javascript,google-chrome,debugging,google-chrome-devtools,console.log
When I console.log an object in Chrome, I see all properties and a method name, but I can't see the contents of the method itself. How can I view the contents of an object's method? I've created a JSFiddle that may help explain what I'm looking for. ...