logger.ts 878 B

1234567891011121314151617181920212223242526272829303132333435
  1. /* eslint-disable no-console */
  2. import * as util from 'util';
  3. import { getBindingError } from 'warthog';
  4. export class Logger {
  5. static info(...args: any[]) {
  6. args = args.length === 1 ? args[0] : args;
  7. console.log(util.inspect(args, { showHidden: false, depth: null }));
  8. }
  9. static error(...args: any[]) {
  10. args = args.length === 1 ? args[0] : args;
  11. console.error(util.inspect(args, { showHidden: false, depth: null }));
  12. }
  13. // static debug(...args: any[]) {
  14. // console.debug(args);
  15. // }
  16. static log(...args: any[]) {
  17. console.log(args);
  18. }
  19. static warn(...args: any[]) {
  20. console.warn(args);
  21. }
  22. // This takes a raw GraphQL error and pulls out the relevant info
  23. static logGraphQLError(error: Error) {
  24. console.error(util.inspect(getBindingError(error), { showHidden: false, depth: null }));
  25. }
  26. }
  27. /* eslint-enable no-console */