File: dtrace-provider.js

package info (click to toggle)
node-dtrace-provider 0.8.8-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 336 kB
  • sloc: cpp: 391; sh: 51; makefile: 2
file content (41 lines) | stat: -rw-r--r-- 1,110 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
var DTraceProvider;

function DTraceProviderStub() {}
DTraceProviderStub.prototype.addProbe = function(name) {
    var p = { 'fire': function () {} };
    this[name] = p;
    return (p);
};
DTraceProviderStub.prototype.enable = function() {};
DTraceProviderStub.prototype.fire = function() {};
DTraceProviderStub.prototype.disable = function() {};

var builds = ['Release', 'default', 'Debug'];
var err = null;

for (var i = 0; i < builds.length; i++) {
    try {
        var binding = require('./src/build/' + builds[i] + '/DTraceProviderBindings');
        DTraceProvider = binding.DTraceProvider;
        break;
    } catch (e) {
        if (err === null) {
            err = e;
        }
    }
}

if (!DTraceProvider) {
    if (process.env.NODE_DTRACE_PROVIDER_REQUIRE === 'hard') {
        throw err;
    } else {
        DTraceProvider = DTraceProviderStub;
    }
}

exports.DTraceProvider = DTraceProvider;
exports.createDTraceProvider = function(name, module) {
    if (arguments.length == 2)
        return (new exports.DTraceProvider(name, module));
    return (new exports.DTraceProvider(name));
};