1
0
Fork 0

Improve logging

This commit is contained in:
Chocobozzz 2025-03-17 10:27:37 +01:00
parent cc7fdc81aa
commit 575ec2beaf
No known key found for this signature in database
GPG key ID: 583A612D890159BE
6 changed files with 30 additions and 19 deletions

View file

@ -145,7 +145,7 @@ function processUndoAnnounce (byActor: MActorSignature, announceActivity: Activi
return sequelizeTypescript.transaction(async t => {
const share = await VideoShareModel.loadByUrl(announceActivity.id, t)
if (!share) {
logger.warn('Unknown video share %d', announceActivity.id)
logger.warn(`Unknown video share ${announceActivity.id}`)
return
}

View file

@ -20,7 +20,7 @@ export async function processMoveToObjectStorage (job: Job) {
const payload = job.data as MoveStoragePayload
if (isMoveVideoStoragePayload(payload)) { // Move all video related files
logger.info('Moving video %s to object storage in job %s.', payload.videoUUID, job.id)
logger.info(`Moving video ${payload.videoUUID} to object storage in job ${job.id}`, lTagsBase(payload.videoUUID))
await moveVideoToStorageJob({
jobId: job.id,
@ -39,7 +39,7 @@ export async function processMoveToObjectStorage (job: Job) {
moveToFailedState: moveToFailedMoveToObjectStorageState
})
} else if (isMoveCaptionPayload(payload)) { // Only caption file
logger.info(`Moving video caption ${payload.captionId} to object storage in job ${job.id}.`)
logger.info(`Moving video caption ${payload.captionId} to object storage in job ${job.id}.`, lTagsBase(payload.captionId))
await moveCaptionToStorageJob({
jobId: job.id,

View file

@ -39,7 +39,7 @@ export async function moveVideoToStorageJob (options: {
const video = await VideoModel.loadWithFiles(videoUUID)
// No video, maybe deleted?
if (!video) {
logger.info('Can\'t process job %d, video does not exist.', jobId, lTagsBase(videoUUID))
logger.info(`Can't process job ${jobId}, video does not exist.`, lTagsBase(videoUUID))
fileMutexReleaser()
return undefined
}
@ -55,27 +55,30 @@ export async function moveVideoToStorageJob (options: {
}
if (video.VideoFiles) {
logger.debug('Moving %d web video files for video %s.', video.VideoFiles.length, video.uuid, lTags)
logger.debug(`Moving ${video.VideoFiles.length} web video files for video ${video.uuid}.`, lTags)
await moveWebVideoFiles(video)
}
if (video.VideoStreamingPlaylists) {
logger.debug('Moving HLS playlist of %s.', video.uuid, lTags)
logger.debug(`Moving HLS playlist of ${video.uuid}.`, lTags)
await moveHLSFiles(video)
}
const captions = await VideoCaptionModel.listVideoCaptions(video.id)
if (captions.length !== 0) {
logger.debug('Moving captions of %s.', video.uuid, lTags)
logger.debug(`Moving captions of ${video.uuid}.`, lTags)
await moveCaptionFiles(captions)
}
const pendingMove = await VideoJobInfoModel.decrease(video.uuid, 'pendingMove')
logger.info(`Moved video ${video.uuid}. Checking pending move.`, lTags, { pendingMove })
if (pendingMove === 0) {
logger.info('Running cleanup after moving files (video %s in job %s)', video.uuid, jobId, lTags)
logger.info(`Running cleanup after moving files (video ${video.uuid} in job ${jobId})`, lTags)
await doAfterLastMove(video)
}
@ -99,7 +102,7 @@ export async function onMoveVideoToStorageFailure (options: {
const video = await VideoModel.loadWithFiles(videoUUID)
if (!video) return
logger.error('Cannot move video %s storage.', video.url, { err, ...lTags })
logger.error(`Cannot move video ${video.url} storage.`, { err, ...lTags })
await moveToFailedState(video)
await VideoJobInfoModel.abortAllTasks(video.uuid, 'pendingMove')

View file

@ -20,7 +20,7 @@ async function processVideoFileImport (job: Job) {
const video = await VideoModel.loadFull(payload.videoUUID)
// No video, maybe deleted?
if (!video) {
logger.info('Do not process job %d, video does not exist.', job.id)
logger.info(`Do not process job ${job.id}, video does not exist.`)
return undefined
}

View file

@ -21,7 +21,7 @@ import { VideoModel } from '../../../models/video/video.js'
type HandlerFunction = (job: Job, payload: VideoTranscodingPayload, video: MVideoFullLight, user: MUser) => Promise<void>
const handlers: { [ id in VideoTranscodingPayload['type'] ]: HandlerFunction } = {
const handlers: { [id in VideoTranscodingPayload['type']]: HandlerFunction } = {
'new-resolution-to-hls': handleHLSJob,
'new-resolution-to-web-video': handleNewWebVideoResolutionJob,
'merge-audio-to-web-video': handleWebVideoMergeAudioJob,
@ -37,7 +37,7 @@ async function processVideoTranscoding (job: Job) {
const video = await VideoModel.loadFull(payload.videoUUID)
// No video, maybe deleted?
if (!video) {
logger.info('Do not process job %d, video does not exist.', job.id, lTags(payload.videoUUID))
logger.info(`Do not process job ${job.id}, video does not exist.`, lTags(payload.videoUUID))
return undefined
}

View file

@ -19,7 +19,6 @@ export type VideoJobInfoColumnType = 'pendingMove' | 'pendingTranscode' | 'pendi
}
]
})
export class VideoJobInfoModel extends SequelizeModel<VideoJobInfoModel> {
@CreatedAt
createdAt: Date
@ -70,7 +69,8 @@ export class VideoJobInfoModel extends SequelizeModel<VideoJobInfoModel> {
const options = { type: QueryTypes.SELECT as QueryTypes.SELECT, bind: { videoUUID } }
const amount = forceNumber(amountArg)
const [ result ] = await VideoJobInfoModel.sequelize.query<{ pendingMove: number }>(`
const [ result ] = await VideoJobInfoModel.sequelize.query(
`
INSERT INTO "videoJobInfo" ("videoId", "${column}", "createdAt", "updatedAt")
SELECT
"video"."id" AS "videoId", ${amount}, NOW(), NOW()
@ -84,7 +84,9 @@ export class VideoJobInfoModel extends SequelizeModel<VideoJobInfoModel> {
"updatedAt" = NOW()
RETURNING
"${column}"
`, options)
`,
options
)
return result[column]
}
@ -92,7 +94,8 @@ export class VideoJobInfoModel extends SequelizeModel<VideoJobInfoModel> {
static async decrease (videoUUID: string, column: VideoJobInfoColumnType): Promise<number> {
const options = { type: QueryTypes.SELECT as QueryTypes.SELECT, bind: { videoUUID } }
const result = await VideoJobInfoModel.sequelize.query(`
const result = await VideoJobInfoModel.sequelize.query(
`
UPDATE
"videoJobInfo"
SET
@ -103,7 +106,9 @@ export class VideoJobInfoModel extends SequelizeModel<VideoJobInfoModel> {
"video"."id" = "videoJobInfo"."videoId" AND "video"."uuid" = $videoUUID
RETURNING
"${column}";
`, options)
`,
options
)
if (result.length === 0) return undefined
@ -113,7 +118,8 @@ export class VideoJobInfoModel extends SequelizeModel<VideoJobInfoModel> {
static async abortAllTasks (videoUUID: string, column: VideoJobInfoColumnType): Promise<void> {
const options = { type: QueryTypes.UPDATE as QueryTypes.UPDATE, bind: { videoUUID } }
await VideoJobInfoModel.sequelize.query(`
await VideoJobInfoModel.sequelize.query(
`
UPDATE
"videoJobInfo"
SET
@ -122,6 +128,8 @@ export class VideoJobInfoModel extends SequelizeModel<VideoJobInfoModel> {
FROM "video"
WHERE
"video"."id" = "videoJobInfo"."videoId" AND "video"."uuid" = $videoUUID
`, options)
`,
options
)
}
}