log.ts 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. 'use strict';
  2. import os = require('os');
  3. export function error(str: string)
  4. {
  5. if (os.platform() === 'win32')
  6. {
  7. console.log(' * ERROR: ' + str);
  8. }
  9. else
  10. {
  11. /* Do more fancy output */
  12. console.error(' \x1B[1;31m* ERROR\x1B[0m: ' + str);
  13. }
  14. }
  15. export function info(str: string)
  16. {
  17. if (os.platform() === 'win32')
  18. {
  19. console.log(' * INFO : ' + str);
  20. }
  21. else
  22. {
  23. /* Do more fancy output */
  24. console.log(' \x1B[1;32m* INFO \x1B[0m: ' + str);
  25. }
  26. }
  27. export function debug(str: string)
  28. {
  29. if (os.platform() === 'win32')
  30. {
  31. console.log(' * DEBUG: ' + str);
  32. }
  33. else
  34. {
  35. /* Do more fancy output */
  36. console.log(' \x1B[1;35m* DEBUG\x1B[0m: ' + str);
  37. }
  38. }
  39. export function warn(str: string)
  40. {
  41. if (os.platform() === 'win32')
  42. {
  43. console.log(' * WARN : ' + str);
  44. }
  45. else
  46. {
  47. /* Do more fancy output */
  48. console.log(' \x1B[1;33m* WARN \x1B[0m: ' + str);
  49. }
  50. }
  51. export function dispEpisode(name: string, status: string, addNL: boolean)
  52. {
  53. if (os.platform() === 'win32')
  54. {
  55. process.stdout.write(' > ' + name + ' : ' + status + '\x1B[0G');
  56. }
  57. else
  58. {
  59. /* Do more fancy output */
  60. process.stdout.write(' \x1B[1;33m> \x1B[37m' + name + '\x1B[0m : \x1B[33m' + status + '\x1B[0m\x1B[0G');
  61. }
  62. if (addNL)
  63. {
  64. console.log('');
  65. }
  66. }