log-entry.ts 823 B

12345678910111213141516171819202122
  1. /**
  2. * Copyright (c) 2018 mol* contributors, licensed under MIT, See LICENSE file for more info.
  3. *
  4. * @author David Sehnal <david.sehnal@gmail.com>
  5. */
  6. export { LogEntry };
  7. interface LogEntry {
  8. type: LogEntry.Type,
  9. timestamp: Date,
  10. message: string
  11. }
  12. namespace LogEntry {
  13. export type Type = 'message' | 'error' | 'warning' | 'info'
  14. export function message(msg: string): LogEntry { return { type: 'message', timestamp: new Date(), message: msg }; }
  15. export function error(msg: string): LogEntry { return { type: 'error', timestamp: new Date(), message: msg }; }
  16. export function warning(msg: string): LogEntry { return { type: 'warning', timestamp: new Date(), message: msg }; }
  17. export function info(msg: string): LogEntry { return { type: 'info', timestamp: new Date(), message: msg }; }
  18. }