Skip to content

Commit

Permalink
Use square brackets for logs
Browse files Browse the repository at this point in the history
Renders more nicely in JSON than quotes which are escaped
  • Loading branch information
toresbe committed Jul 24, 2023
1 parent 5e11747 commit 652ed0e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ process
});

const initCaspar = async () => {
log.info(`Connecting to CasparCG host "${caspar.host}"...`);
log.info(`Connecting to CasparCG host [${caspar.host}]...`);
await caspar.connect();

log.info(`Clearing all layers...`);
Expand Down
18 changes: 9 additions & 9 deletions src/scheduling/ScheduledVideo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ export class ScheduledVideo implements ScheduleItem {
)?.url;

if (typeof fallback === "undefined") {
throw new Error(`No broadcastable or webm asset for "${this.label}"`);
throw new Error(`No broadcastable or webm asset for [${this.label}]`);
}

log.error(`No broadcastable asset for "${this.label}", using webm`);
log.error(`No broadcastable asset for [${this.label}], using webm`);

return fallback;
}
Expand All @@ -40,21 +40,21 @@ export class ScheduledVideo implements ScheduleItem {
}

loadbg = async () => {
log.info(`Loading video "${this.entry.video.title}"`);
log.info(`Loading video [${this.entry.video.title}]`);

await caspar.loadbg({ ...VIDEO_LAYER, clip: this.getFilename() });
};

stop = async (_: Date) => {
log.info(`Stopping video "${this.entry.video.title}"`);
log.info(`Stopping video [${this.entry.video.title}]`);

await caspar.stop(VIDEO_LAYER);
};

play = async (_: Date, seekSeconds: number = 0) => {
const seek = seekSeconds ? seekSeconds * CHANNEL_FPS : undefined;

log.info(`Playing video "${this.entry.video.title}"`);
log.info(`Playing video [${this.entry.video.title}]`);
if (seek) log.info(`Seeking ${seekSeconds} seconds`);

await caspar.play({
Expand All @@ -71,18 +71,18 @@ export class ScheduledVideo implements ScheduleItem {

if (endsAt <= now) {
const endTime = compactDate(endsAt);
log.debug(`Not scheduling "${label}" (end ${endTime} is in the past)`);
log.debug(`Not scheduling [${label}] (end ${endTime} is in the past)`);
return;
}

if (startsAt <= now) {
log.warn(`Video "${label}" should already be playing, seeking...`);
log.warn(`Video [${label}] should already be playing, seeking...`);
await this.play(new Date(), differenceInSeconds(now, startsAt));
timeline.addEvent(this, endsAt, "stop", stop);
return;
}

log.debug(`Arming timer for ${compactTimestamp(this)} "${label}"`);
log.debug(`Arming timer for ${compactTimestamp(this)} [${label}]`);
timeline.addEvent(this, loadsAt, "load", loadbg);
timeline.addEvent(this, startsAt, "start", play);
timeline.addEvent(this, endsAt, "stop", stop);
Expand All @@ -91,7 +91,7 @@ export class ScheduledVideo implements ScheduleItem {
async disarm() {
const { label } = this;

log.debug(`Disarming: Video "${label}" at ${compactTimestamp(this)}`);
log.debug(`Disarming: Video [${label}] at ${compactTimestamp(this)}`);

await timeline.remove(this);
}
Expand Down

0 comments on commit 652ed0e

Please sign in to comment.