Code Monkey home page Code Monkey logo

brout.js's People

Contributors

cool-blue avatar dy avatar mantoni avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

cool-blue

brout.js's Issues

Referencing Bug

Hi, this is really cool, I'm a big fan of isomorphic code and yours is super elegant...

I noticed small issue though: when there are no listeners, stdout always writes to info and stderror to warn instead of log and error respectively. I figured out why...

Take log and info for example.
because you did this

console.info  = console.log

when you do this

console.log.original   = originalLog;
console.info.original  = originalInfo;

your actually doing this

console.log.original   = originalLog;
console.log.original  = originalInfo;

because console.info is already console.log, so the .original member resolves to console.log.original. That's why stdout is logging to the info channel.

The easy fix is to replace this code

redirectLog('log', 'stdout');
redirectLog('warn', 'stderr');
console.info  = console.log;
console.error = console.warn;

with this

redirectLog('log', 'stdout');
redirectLog('info', 'stdout');
redirectLog('warn', 'stderr');
redirectLog('error', 'stderr');

... if you want to keep that functionality.
For me I would prefer to keep the info and warn channels free since, technically, they don't map onto node. Therefore I would suggest this...

redirectLog('log', 'stdout');
redirectLog('error', 'stderr');

If used by other consumers of brout, can get a stack overflow on write

When I was testing using your mocaccino, I realised that, if the logs are already rewired before the code hits the test, console.xxx.original will already point to process.write which will cause a stack overflow.

Suggested fix in brout is:

var originalLog   = console.log.original || console.log;
var originalInfo  = console.info.original || console.info;
var originalWarn  = console.warn.original || console.warn;
var originalError = console.error.original || console.error;

As long as the outer code also has this patch, you will always get the correct logger.

test script will not run in windows

Hi, just to follow up on my comment in the PR...
./test/*.js is not resolved when I run this in windows so npm throws.

I had to change it to ./test/brout-test.js.

TypeError: 'undefined' is not an object (evaluating 'process.stdout.write')

Hi @mantoni . I do exactly the readme case:

myscript.js:

process.stdout.write('Hello stdout!\n');
console.log('Hello %s!', 'console');

$ browserify -t brout test/myscript.js | phantomic

And get this error:

TypeError: 'undefined' is not an object (evaluating 'process.stdout.write')
    at http://localhost:55036/js/bundle:91
    at http://localhost:55036/js/bundle:93
    at http://localhost:55036/js/bundle:1
    at http://localhost:55036/js/bundle:1
    at http://localhost:55036/js/bundle:94

Seems that that mishap breaks macoccino and mochify: mantoni/mochify.js#54

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.