Skip to content
This repository was archived by the owner on Nov 5, 2018. It is now read-only.
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
5dbfaa6
repaired the ability of nano to be able to log its messages when a us…
glynnbird Jun 25, 2015
04386c1
version bump for dependencies
glynnbird Oct 26, 2016
d1c7554
fix mocked tests
glynnbird Oct 26, 2016
45d58bf
modified tests to work with latest dependencies and CouchDB 2.0
glynnbird Oct 26, 2016
225f151
Test with 4.2 (LTS) and 5.5 (Stable)
revington Jan 25, 2016
3a5a758
removed the osx target since it is not supported by travis
revington Jan 28, 2016
4aac563
Update README.md
briandela Feb 9, 2016
93db52d
Add db.info doc.
satazor Feb 26, 2016
118e209
Ensure fetch params is optional, fixes #319.
satazor Mar 26, 2016
f757cdd
ct: Test for optional body in db.atomic
cttttt Apr 23, 2016
6b5d723
ct: Allow body to be optional in db.atomic.
cttttt Apr 23, 2016
a255f68
ct: Fix mocks.
cttttt Apr 23, 2016
3db2d95
Validate docName parameter to avoid db delete
KangTheTerrible Apr 25, 2016
6be3aec
Update express.js example for nano 6 and express 4
pmanijak May 9, 2016
cb870b8
modify tests to work mocked and unmocked with CouchDB 2.0 from Docker
glynnbird Oct 26, 2016
939c980
ensure CouchDB 2.0 Docker is stopped after each test run
glynnbird Oct 27, 2016
4e38f22
add reference to server in doc scope
dominicbarnes Jan 10, 2017
29bc803
Nano improvements
glynnbird Nov 3, 2016
32cc15c
Ensure 'qs' is real whenever qs will be manipulated.
idearat Feb 11, 2017
a20fb95
Adding replication using the "_replicator" database
carlosduclos Feb 2, 2017
e7f532c
Merge remote-tracking branch 'upstream/master'
glynnbird Mar 28, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -804,6 +804,32 @@ alice.attachment.get('rabbit', 'picture.png').pipe(fs.createWriteStream('/tmp/ra

then open `/tmp/rabbit.png` and you will see the rabbit picture.

### debugging
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

docs. always great 👍


debugging messages can be enabled in Nano by


#### setting the DEBUG environment variable

Either in the shell

export DEBUG=nano
# then run your Node.js script

or on the same line as you execute your Node.js script:

DEBUG=nano node myscript.js

#### providing your own debugging function

when initialising Nano, pass in a `log` function:

``` js
nano = require('nano')({ url: 'http://127.0.0.1:5984/', log: function(d) { console.log("!!!",d)}} );
```

* setting an environment variable `DEBUG` with value of 'nano'
* or, providing

## tutorials, examples in the wild & screencasts

Expand Down
18 changes: 6 additions & 12 deletions lib/logger.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,12 @@
// the License.

'use strict';
var prefix = 'nano';
var debug = require('debug')(prefix);

var debug = require('debug')('nano/logger');

module.exports = function logging(cfg) {
var log = cfg && cfg.log;
var logStrategy = typeof log === 'function' ? log : debug;

return function logEvent(prefix) {
var eventId = (prefix ? prefix + '-' : '') +
(~~(Math.random() * 1e9)).toString(36);
return function log() {
logStrategy.call(this, eventId, [].slice.call(arguments, 0));
};
module.exports = function logging() {
return function log() {
var eventId = prefix + (~~(Math.random() * 1e9)).toString(36);
debug.call(this, eventId, [].slice.call(arguments, 0));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for the pull request. however i'm confused by this.

the log function is normally used to log, and during development can be overridden by debug. seems like this just makes it be a debug message all the time no?

};
};
11 changes: 3 additions & 8 deletions tests/integration/shared/log.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,7 @@ var harness = helpers.harness(__filename);
var it = harness.it;

it('should be able to instantiate a log', function(assert) {
var log = logger({
log: function(id, msg) {
assert.equal(typeof id, 'string', 'id is set `' + id + '`');
assert.equal(msg[0], 'testing 1234');
assert.end();
}
})();
log('testing 1234');
var log = logger();
assert.equal(typeof log, 'function');
assert.end();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

once again, seems like you removed api stable behavior and replaced it with what was convenient for your use case?

while you might not like the behavior, many people might be relying on it in production and we can't do breaking changes like this

if you have a rationale for it please explain, maybe a breaking version can be released then

});