Nutella Pancake Machine

    logobj

    0.0.4 • Public • Published

    logobj

    Build Status Dependency Status Code Climate

    Object to File Logger for Node

    Install

    npm install logobj

    Usage

    logobj([<filename>,] <data> [, <options>]);

    var logobj = require('logobj');
    // ...
    logobj(data);
    // or
    logobj('myfile.json', data);
    // or
    logobj('myfile.json', data, options);

    Parameters

    filename (optional)

    • Name of file to write data to.
    • Date/time will be appended to the name before the extension. (Can be disabled - see options below)
    • If not specified then a UUID will be used with the dashes removed and '.json' appended.

    data

    • The data that you want to write to the file.
    • If it's not an object then it will be encapsulated inside an object.
    • The data will be pretty printed (also called beautified or beautification).

    options (optional)

    The default options are show below with comments.

    {
      // The filename options determine how the filename is created
      filename: {
        // Change to true to suppress adding a date/time stamp to the filename
        nodate: false,
        // Change the date/time format in the filename
        dateFormat: 'YYYYMMDDhhmmss',
        // Prepend the date instead of appending when true
        leadDate: false,
        // Append .json if file doesn't end in .json
        appendJson: false
      },
      // indent and serializer are used by the JSON.stringify() method
      // Number of characters to use for indenting
      indent: 2,
      // Serializer that should be used by JSON.stringify()
      serializer: null,
      // fs.writeFile() is used to write the file.
      // Pass any options that fs.writeFile() accepts in this object.
      fsOptions: {
        encoding: 'utf8'
      }
    }

    Install

    npm i logobj

    DownloadsWeekly Downloads

    0

    Version

    0.0.4

    License

    MIT

    Last publish

    Collaborators

    • guyellis