| 12 | } |
| 13 | |
| 14 | export class DevLogger { |
| 15 | private options: DevLoggerOptions; |
| 16 | |
| 17 | constructor(options: DevLoggerOptions = {}) { |
| 18 | this.options = { |
| 19 | timestamp: false, |
| 20 | colors: true, |
| 21 | ...options, |
| 22 | }; |
| 23 | } |
| 24 | |
| 25 | private formatTime(): string { |
| 26 | if (!this.options.timestamp) return ''; |
| 27 | return pc.dim(new Date().toLocaleTimeString()); |
| 28 | } |
| 29 | |
| 30 | private formatPrefix(text: string, color: (str: string) => string): string { |
| 31 | const time = this.formatTime(); |
| 32 | const prefix = pc.bold(color(text)); |
| 33 | return time ? `${time} ${prefix}` : prefix; |
| 34 | } |
| 35 | |
| 36 | info(message: string): void { |
| 37 | const prefix = this.formatPrefix('◐', pc.cyan); |
| 38 | console.info(`${prefix} ${message}`); |
| 39 | } |
| 40 | |
| 41 | success(message: string): void { |
| 42 | const prefix = this.formatPrefix('✓', pc.green); |
| 43 | console.info(`${prefix} ${pc.green(message)}`); |
| 44 | } |
| 45 | |
| 46 | warn(message: string): void { |
| 47 | const prefix = this.formatPrefix('⚠', pc.yellow); |
| 48 | console.info(`${prefix} ${pc.yellow(message)}`); |
| 49 | } |
| 50 | |
| 51 | error(message: string): void { |
| 52 | const prefix = this.formatPrefix('✗', pc.red); |
| 53 | console.info(`${prefix} ${pc.red(message)}`); |
| 54 | } |
| 55 | |
| 56 | starting(): void { |
| 57 | const prefix = this.formatPrefix('◇', pc.blue); |
| 58 | console.info(`${prefix} ${pc.blue('Starting Mastra dev server...')}`); |
| 59 | } |
| 60 | |
| 61 | ready( |
| 62 | host: string, |
| 63 | port: number, |
| 64 | studioBasePath: string, |
| 65 | apiPrefix: string, |
| 66 | startTime?: number, |
| 67 | https?: HTTPSOptions, |
| 68 | ): void { |
| 69 | let protocol = 'http'; |
| 70 | if (https && https.key && https.cert) { |
| 71 | protocol = 'https'; |
nothing calls this directly
no outgoing calls
no test coverage detected
searching dependent graphs…