Logging

Patio uses the comb.logging framework for all logging. To set up logging there are two scenarios.

If you installed comb at the root of your project and then installed patio

npm install comb patio

Then patio should be using the same version of comb that your application uses. If that is the case then you can configure logging through

  1. var comb = require("comb"),
  2. patio = require("patio");
  3. comb.logger.configure();
  4. comb.logger("patio").level = "info";

Or

  1. //configure with a JSON file.
  2. comb.logger.configure("/location/of/log/config.json");
  3. //or
  4. var loggingConfig = {
  5. //set the root patio logger to INFO by setting it on the root patio logger, patio.Dataset, patio.Database will
  6. //all get set to INFO level.
  7. "patio" : {
  8. level : "INFO",
  9. appenders : [
  10. {
  11. type : "ConsoleAppender"
  12. }
  13. ]
  14. },
  15. //set the database logger to DEBUG
  16. "patio.Database" : {
  17. level : "DEBUG",
  18. appenders : [
  19. {
  20. type : "ConsoleAppender"
  21. }
  22. ]
  23. }
  24. };
  25. comb.logger.configure(loggingConfig);

If you are using a different version of comb or do not want to use comb, then you can use the following method patio.configureLogging;

  1. var comb = require("comb"),
  2. patio = require("patio");
  3. //sets up a basic configurator
  4. patio.configureLogging();

Or with a JSON file

  1. patio.configureLogging("/location/of/log/config.json");

Or with an object

  1. var loggingConfig = {
  2. //set the root patio logger to INFO by setting it on the root patio logger, patio.Dataset, patio.Database will
  3. //all get set to INFO level.
  4. "patio" : {
  5. level : "INFO",
  6. appenders : [
  7. {
  8. type : "ConsoleAppender"
  9. },
  10. {
  11. type:"RollingFileAppender",
  12. file:"/var/log/patio.log"
  13. }
  14. ]
  15. },
  16. //set the database logger to DEBUG
  17. "patio.Database" : {
  18. level : "DEBUG",
  19. appenders : [
  20. {
  21. type : "ConsoleAppender"
  22. }
  23. ]
  24. }
  25. };
  26. patio.configureLogging(loggingConfig);

The patio logger currently contains the following loggers:

To get access to patios root logger use the patio.LOGGER property.

  1. var patioLogger = patio.LOGGER;
  2. patioLogger.level = "off";

There are also a methods for each logger method on patio.

  1. patio.logDebug("DEBUG");
  2. patio.logInfo("INFO");
  3. patio.logTrace("TRACE");
  4. patio.logError("ERROR");
  5. patio.logWarn("WARN");
  6. patio.logFatal("FATAL");

Documentation generated using coddoc.