title: Sinon spy on console.log call not registered
body: <p>I'm trying to learn about Sinon and want to spy on <code>console.log</code>. The code is simple:</p>
  
  <pre><code>function logToConsole() {
      console.log('Hello World');
  }
  
  exports.logToConsole = logToConsole;
  </code></pre>
  
  <p>But if I want to test it, it doesn't work because the call to <code>console.log</code> is not registered inside the system under test:</p>
  
  <pre><code>var chai = require('chai'),
      expect = chai.expect,
      sinonChai = require('sinon-chai'),
      sinon = require('sinon'),
      sut = require('../src/logToConsole');
  
  chai.use(sinonChai);
  
  describe('logToConsole', function() {
      it('should spy on console.log', function() {
          sinon.spy(console, 'log');
  
          sut.logToConsole();
  
          expect(console.log).to.have.been.called;
      });
  });
  </code></pre>
  
  <p>However if I execute <code>console.log</code> inside the test itself, it is captured and passes:</p>
  
  <pre><code>it('should spy on console.log', function() {
      sinon.spy(console, 'log');
  
      sut.logToConsole();
      console.log('Test');
  
      expect(console.log).to.have.been.called;
  });
  </code></pre>
  
  <p>Interestingly, it doesn't seem to be able to spy on inner-function calls at all. Is this not the purpose of a spying library?</p>
  
  <p>e.g.</p>
  
  <pre><code>function a() {};
  
  function b() {
      a();
  }
  </code></pre>