-
Notifications
You must be signed in to change notification settings - Fork 247
.log, .error, .debug
Alexander Ivanov edited this page May 7, 2018
·
2 revisions
Osmosis has 3 different logging commands: log
, error
, and debug
. Each of these takes a callback function with just one argument: the message being logged. Logging functions can be placed multiple times at any point along the command chain. This allows you control what gets logged where and helps in tracking down any errors.
General logging, such as:
- URL being followed
- URL loaded
- Number of elements found
Error logging, such as:
- HTTP errors
- Parse errors
- No elements found
Debugging, such as:
- Process stats (stack size, RAM Usage, total HTTP requests)
osmosis
.get('example.com/items')
...
.find('li.item')
.log(function(msg) {
fs.writeFileSync(logFile, 'li.item - '+msg)
})
...
.log(console.log)
.error(console.error)
.debug(util.debug)