log.js 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. /*
  2. * Copyright (c) 2014-2015 Sylvain Peyrefitte
  3. *
  4. * This file is part of node-rdpjs.
  5. *
  6. * node-rdpjs is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation, either version 3 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  18. */
  19. var Levels = {
  20. 'DEBUG': 1,
  21. 'INFO': 2,
  22. 'WARN': 3,
  23. 'ERROR': 4,
  24. 'NONE': 5
  25. }
  26. /*
  27. var Logger = require('bunyan');
  28. let logStreams = [];
  29. if (process.env.enable_log_file === 'true') {
  30. logStreams.push(
  31. {
  32. type: 'rotating-file',
  33. period: '1d',
  34. count: 2,
  35. path: `node-rdpjs${process.pid}.log`,
  36. level: process.env.log_level
  37. }
  38. );
  39. }
  40. logStreams.push(
  41. {
  42. stream: process.stderr,
  43. level: process.env.log_level
  44. }
  45. );
  46. var logger = Logger.createLogger({
  47. name: 'node-rdpjs',
  48. streams: logStreams
  49. });
  50. */
  51. function log(level, message) {
  52. if (Levels[level] < module.exports.level) return;
  53. console.log("[node-rdpjs] " + level + ":\t" + message);
  54. }
  55. /**
  56. * Module exports
  57. */
  58. module.exports = {
  59. level: Levels.INFO, // Levels.INFO,
  60. Levels: Levels,
  61. debug: function (message) {
  62. //console.log(message);
  63. //logger.debug(message);
  64. },
  65. info: function (message) {
  66. //console.log(message);
  67. //logger.info(message);
  68. },
  69. warn: function (message) {
  70. //console.log(message);
  71. //logger.warn(message);
  72. },
  73. error: function (message) {
  74. //console.log(message);
  75. //logger.error(message);
  76. }
  77. };