Logging object with console.log

See: https://developer.mozilla.org/en-US/docs/Web/API/console#Outputting_text_to_the_console

$ node

> console.log('object: %o', console)

object: Console {
  [_stdout]:
   WriteStream {
     connecting: false,
     _hadError: false,
     _handle:
      TTY {
        onread:
         { [Function: onStreamRead]
           [length]: 2,
           [name]: 'onStreamRead',
           [prototype]: onStreamRead { [constructor]: [Circular] } },
        [Symbol(owner)]: [Circular] },
     _parent: null,
     _host: null,
     _readableState:
      ReadableState {
        objectMode: false,
        highWaterMark: 16384,
        buffer: BufferList { head: null, tail: null, length: 0 },
...
        [Symbol(kFormatForStderr)]:
         { [Function]
           [length]: 1,
           [name]: '',
           [prototype]: { [constructor]: [Circular] } } } },
  markTimeline:
   { [Function: markTimeline] [length]: 1, [name]: 'markTimeline' },
  profile: { [Function: profile] [length]: 1, [name]: 'profile' },
  profileEnd: { [Function: profileEnd] [length]: 1, [name]: 'profileEnd' },
  timeline: { [Function: timeline] [length]: 1, [name]: 'timeline' },
  timelineEnd:
   { [Function: timelineEnd] [length]: 1, [name]: 'timelineEnd' },
  timeStamp: { [Function: timeStamp] [length]: 1, [name]: 'timeStamp' },
  context: { [Function: context] [length]: 1, [name]: 'context' },
  [Symbol(counts)]: Map {},
  [Symbol(kColorMode)]: 'auto',
  [Symbol(kGroupIndent)]: '' }
$ node

> console.log(console)
Console {
  log: [Function: bound consoleCall],
  debug: [Function: bound consoleCall],
  info: [Function: bound consoleCall],
  dirxml: [Function: bound consoleCall],
  warn: [Function: bound consoleCall],
  error: [Function: bound consoleCall],
  dir: [Function: bound consoleCall],
  time: [Function: bound consoleCall],
  timeEnd: [Function: bound consoleCall],
  timeLog: [Function: bound timeLog],
  trace: [Function: bound consoleCall],
  assert: [Function: bound consoleCall],
  clear: [Function: bound consoleCall],
  count: [Function: bound consoleCall],
  countReset: [Function: bound consoleCall],
  group: [Function: bound consoleCall],
  groupCollapsed: [Function: bound consoleCall],
  groupEnd: [Function: bound consoleCall],
  table: [Function: bound consoleCall],
  Console: [Function: Console],
  markTimeline: [Function: markTimeline],
  profile: [Function: profile],
  profileEnd: [Function: profileEnd],
  timeline: [Function: timeline],
  timelineEnd: [Function: timelineEnd],
  timeStamp: [Function: timeStamp],
  context: [Function: context],
  [Symbol(counts)]: Map {},
  [Symbol(kColorMode)]: 'auto' }

Leave a Comment

Your email address will not be published. Required fields are marked *