How to use the info function from npmlog

Find comprehensive JavaScript npmlog.info code examples handpicked from public code repositorys.

npmlog.info is a function in the npmlog library that logs an informational message to the console with the prefix "info:".

15
16
17
18
19
20
21
22
23
24

process.on('exit', function (code) {
  log.disableProgress()
  if (!npm.config || !npm.config.loaded) return
  if (code) itWorked = false
  if (itWorked) log.info('ok')
  else {
    if (!cbCalled) {
      log.error('', 'cb() never called!')
    }
fork icon11
star icon113
watch icon6

+ 3 other calls in file

62
63
64
65
66
67
68
69
70
71
      .concat(libsFoundInDir.map(lib => '-lopencv_' + lib.opencvModule))
      .concat('-Wl,-rpath,' + libDir)

console.log()
log.info('install', 'setting the following defines:')
defines.forEach(def => log.info('defines', def))
console.log()
log.info('install', 'setting the following includes:')
includes.forEach(inc => log.info('includes', inc))
console.log()
fork icon793
star icon0
watch icon136

+ 77 other calls in file

How does npmlog.info work?

npmlog.info is a function in the npmlog library that logs an informational message to the console with the prefix "info:". It takes two arguments: the first is a string that represents the name of the module that is logging the message, and the second is a message string to be logged. The npmlog library is commonly used in Node.js projects to log messages to the console or to a file. It provides several logging levels, including silly, verbose, info, warn, and error, each of which can be used to convey different types of messages. When npmlog.info is called, it checks the current logging level set in the npmlog instance to determine whether the message should actually be logged. If the logging level is set to silly, verbose, info, or warn, the message will be logged to the console along with the prefix "info:". If the logging level is set to error, the message will not be logged, since npmlog.info is not an error-level log method. By default, npmlog uses the global console object to log messages, but it can be configured to use a custom logger function or to write messages to a file instead.

96
97
98
99
100
101
102
103
104
105
app.use(logger(config.www.log, {
    stream: {
        write: message => {
            message = (message || '').toString();
            if (message) {
                log.info('HTTP', message.replace('\n', '').trim());
            }
        }
    }
}));
fork icon702
star icon4
watch icon2

+ 3 other calls in file

32
33
34
35
36
37
38
39
createDump(err => {
    if (err) {
        log.error('sqldump', err);
        process.exit(1);
    }
    log.info('sqldump', 'MySQL Dump Completed');
    process.exit(0);
});
fork icon702
star icon0
watch icon116

+ 13 other calls in file

Ai Example

1
2
3
const npmlog = require("npmlog");

npmlog.info("myapp", "Hello, world!");

In this example, we import the npmlog library and then call npmlog.info with the string "myapp" as the module name and "Hello, world!" as the message. When this code is executed, npmlog will log the message "info: myapp Hello, world!" to the console.

163
164
165
166
167
168
169
170
171
172
    this.debug('Unknown pin mode')
  }
}
GrovePi.prototype.debug = function(msg) {
  if (this.debugMode)
    log.info('GrovePi.board', msg)
}
GrovePi.prototype.wait = function(ms) {
  sleep.usleep(1000 * ms)
}
fork icon488
star icon483
watch icon0

+ 3 other calls in file

15
16
17
18
19
20
21
22
23
}

TapConsumer.prototype = {
  __proto__: EventEmitter.prototype,
  onTapAssert: function(data) {
    log.info(data);
    if (data.skip) {
      return;
    }
fork icon415
star icon0
watch icon17

94
95
96
97
98
99
100
101
102
103
this.viewRunners.push(viewRunner);

var idx = this.viewRunners.length - 1;
this.x[runner.launcherId] = viewRunner;

log.info('runnerAdded', runner.name(), runner.launcherId);

var tab = new RunnerTab({
  runner: viewRunner,
  index: idx,
fork icon414
star icon0
watch icon17

+ 7 other calls in file

95
96
97
98
99
100
101
102
103
104
  this.runnerTabs.push(tab);
  this.set('atLeastOneRunner', this.viewRunners.length > 0);
},

runnerRemoved(runner) {
  log.info('runnerRemoved');

  this.viewRunners.remove(this.x[runner.launcherId]);
  this.set('atLeastOneRunner', this.viewRunners.length > 0);
},
fork icon414
star icon0
watch icon3

+ 7 other calls in file

132
133
134
135
136
137
138
139
140
141
// No devices to notify, hit the callback now
if (!devices.length) cb();

// This will be called after each request, but only do anything after the final request
var updateCachedDevices = function() {
  // log.info('updateCachedDevices', `sent count: ${sent}`);
  
  // If number of messages sent matches the number of devices...
  if (sent >= devices.length) {
    // log.info('updateCachedDevices', 'sent matches device length');
fork icon9
star icon20
watch icon7

+ 5 other calls in file

11
12
13
14
15
16
17
18
19
20

function mutateModule(repo, callback){
  assert(repo instanceof Repo)
  assert(typeof callback === 'function')

  log.info(repo, 'mutating module')
  fs.readFile(path.join(repo.dirpath(), 'component.json'), function(err, data){
    if (err) {
      if (err.code === 'ENOENT'){
        log.error(repo, 'component.json not found.')
fork icon0
star icon10
watch icon2

+ 11 other calls in file

64
65
66
67
68
69
70
71
72
73
    addNameTag(name, version, data, cb)
  }
}

function addNameTag (name, tag, data, cb) {
  log.info('addNameTag', [name, tag])
  var explicit = true
  if (!tag) {
    explicit = false
    tag = npm.config.get('tag')
fork icon322
star icon0
watch icon2

+ 11 other calls in file

145
146
147
148
149
150
151
152
153
154
  })
}

// don't try too hard to hold on to a remote
function resetRemote (from, cloneURL, treeish, cachedRemote, cb) {
  log.info('resetRemote', 'resetting', cachedRemote, 'for', from)
  rm(cachedRemote, function (er) {
    if (er) return cb(er)
    mirrorRemote(from, cloneURL, treeish, cachedRemote, false, cb)
  })
fork icon322
star icon0
watch icon2

49
50
51
52
53
54
55
56
57
58
  Bucket: config.bucket
};
log.info('publish', 'Putting object', s3_put_opts.ACL, s3_put_opts.Bucket, s3_put_opts.Key);
try {
  s3.putObject(s3_put_opts, (err2, resp) => {
    log.info('publish', 'returned from putting object');
    if (err2) {
      log.info('publish', 's3 putObject error: "' + err2 + '"');
      return callback(err2);
    }
fork icon258
star icon0
watch icon0

+ 129 other calls in file

107
108
109
110
111
112
113
114
115
116

        plugins.init('receiver');
        plugins.handler.load(() => {
            log.verbose('Plugins', 'Plugins loaded');
            plugins.handler.runHooks('init', [], () => {
                log.info('App', 'All servers started, ready to process some mail');
            });
        });
    });
});
fork icon245
star icon0
watch icon54

+ 35 other calls in file

40
41
42
43
44
45
46
47
48
};

npmlog.level = req.options['log-level'];

if (req.parameters.glob) {
        npmlog.info('init', `Locating files matching "${req.parameters.glob}"`);
}

npmlog.info('init', `Reading schema from "${req.parameters.schematron}"`);
fork icon2
star icon9
watch icon4

+ 9 other calls in file

23
24
25
26
27
28
29
30
31

const members = list.members.map(member => (
  _.pick(member, ['id', 'status', 'email_address', 'merge_fields'])
))

log.info(logGroup, `Found ${members.length} mailchimp audience members.`)

options.debug &&
  console.log(JSON.stringify(members, null, 2))
fork icon72
star icon158
watch icon0

+ 15 other calls in file

59
60
61
62
63
64
65
66
67
68

const {result} = await pify(travis.hooks(travis.repoid).put.bind(travis))({
  hook: {active: true},
});
if (!result) throw new Error('Could not enable hook on Travis CI');
log.info('Successfully created Travis CI hook.');

await setEnvVar(travis, 'GH_TOKEN', info.github.token);

if (info.npm.authmethod === 'token') {
fork icon46
star icon347
watch icon8

+ 15 other calls in file

30
31
32
33
34
35
36
37
38
39
}

// Generate each letter icon "synchronously"
async.eachSeries(letters, function(letter, cbAsync) {
    // Log current letter
    log.info('material-letter-icons', 'Generating icon: ' + letter);
    
    // Generate an icon for the current letter
    generateLetterIcon(letter, function(err) {
        // Handle errors
fork icon25
star icon89
watch icon8

7
8
9
10
11
12
13
14
15
16
  npmlog.error('', message)
}

npmlog.style.info.fg = 'yellow'
function info (message) {
  npmlog.info('', message)
}

npmlog.addLevel('start', 2001, { fg: 'blue' })
function start (message) {
fork icon26
star icon1
watch icon2

+ 3 other calls in file

110
111
112
113
114
115
116
117
118
    server.listen(config.acme.agent.port, config.acme.agent.host, () => {
        if (started) {
            return server.close();
        }
        started = true;
        log.info('ACME', 'Server listening on %s:%s', config.acme.agent.host || '0.0.0.0', config.acme.agent.port);
        done(null, server);
    });
};
fork icon245
star icon0
watch icon54

+ 7 other calls in file