Module: log

log

Interception module for logging usage, performance and error information about data provider methods.

By default the interceptor uses winston library for logging. Winston can be configured as you would normally do. Please see winston documentation. To set custom logger, use options.logger property.

For more details on using interceptors please see the Interceptors tutorial.

Source:

Examples

 var entree  = require("entree"),
     log     = entree.resolveInterceptor("log"),
     opts    = {
         level: "info",
         log: {
             action: true,
             query: true
         }
     };

entree.posts.use(log.interception(opts, ["insert", "update", "delete"]));
 var options = {
     logger: require("path/to/logger"); // or an instance of winston logger
 };

provider.use(log.interception(options));

Methods

<static> interception(opts, actions) → {function}

Configures and returns an interceptor function.

Options

  • logger {Object}, logger instance, if omitted default winston instance is used.
  • level {String}, logging level for actions in normal flow. Default is "info".
  • errorLevel {String}, logging level for errors. Default is "error".
  • log {Object}, defines what type of information should be logged. By default only actions are logged.
    • action {Boolean}, logs the name of the intercepted method. Default is true.
    • profile {Boolean}, profiles, logs execution duration, for all intercepted methods in milliseconds. Default is false.
    • query {Boolean}, logs the "query" argument of the intercepted method as metadata. Default is false.
    • context {Boolean}, logs the "context" argument of the intercepted method as metadata. Default is false.
    • result {Boolean}, logs the result returned by the intercepted method as metadata. NOTE: This is potentially dangerous option for select method if the returned result set is very large. Default is false.
    • error {Boolean}, logs error message if an error was returned by the intercepted method. Default is false.
Parameters:
Name Type Argument Description
opts object <optional>

Logger options.

actions string | Array.<string> <optional>

Specifies which actions should be logged. Could be single action or an array of actions. If omitted, all actions are logged. Possible values are: ["insert", "upsert", "update", "get", "delete", "select"]

Source:
Returns:
Type
function
EntreeJS Copyright © 2013-2014 The contributors to the EntreeJS project.
Documentation generated by JSDoc 3.2.2 on Mon May 26 2014 17:43:42 GMT+0300 (EEST) using the DocStrap template.