From 452b3bea082481b84537e55c7cedc1e24860d543 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 5 Mar 2021 13:26:02 +0100 Subject: Introduce tags to the logger That could help to filter unneeded logs and/or select particular components --- server/lib/activitypub/send/send-create.ts | 10 ++++++---- server/lib/activitypub/share.ts | 23 ++++++++++++++--------- 2 files changed, 20 insertions(+), 13 deletions(-) (limited to 'server/lib/activitypub') diff --git a/server/lib/activitypub/send/send-create.ts b/server/lib/activitypub/send/send-create.ts index 9fb218224..baded642a 100644 --- a/server/lib/activitypub/send/send-create.ts +++ b/server/lib/activitypub/send/send-create.ts @@ -4,7 +4,7 @@ import { VideoPrivacy } from '../../../../shared/models/videos' import { VideoCommentModel } from '../../../models/video/video-comment' import { broadcastToActors, broadcastToFollowers, sendVideoRelatedActivity, unicastTo } from './utils' import { audiencify, getActorsInvolvedInVideo, getAudience, getAudienceFromFollowersOf, getVideoCommentAudience } from '../audience' -import { logger } from '../../../helpers/logger' +import { logger, loggerTagsFactory } from '../../../helpers/logger' import { VideoPlaylistPrivacy } from '../../../../shared/models/videos/playlist/video-playlist-privacy.model' import { MActorLight, @@ -18,10 +18,12 @@ import { import { getServerActor } from '@server/models/application/application' import { ContextType } from '@shared/models/activitypub/context' +const lTags = loggerTagsFactory('ap', 'create') + async function sendCreateVideo (video: MVideoAP, t: Transaction) { if (!video.hasPrivacyForFederation()) return undefined - logger.info('Creating job to send video creation of %s.', video.url) + logger.info('Creating job to send video creation of %s.', video.url, lTags(video.uuid)) const byActor = video.VideoChannel.Account.Actor const videoObject = video.toActivityPubObject() @@ -37,7 +39,7 @@ async function sendCreateCacheFile ( video: MVideoAccountLight, fileRedundancy: MVideoRedundancyStreamingPlaylistVideo | MVideoRedundancyFileVideo ) { - logger.info('Creating job to send file cache of %s.', fileRedundancy.url) + logger.info('Creating job to send file cache of %s.', fileRedundancy.url, lTags(video.uuid)) return sendVideoRelatedCreateActivity({ byActor, @@ -51,7 +53,7 @@ async function sendCreateCacheFile ( async function sendCreateVideoPlaylist (playlist: MVideoPlaylistFull, t: Transaction) { if (playlist.privacy === VideoPlaylistPrivacy.PRIVATE) return undefined - logger.info('Creating job to send create video playlist of %s.', playlist.url) + logger.info('Creating job to send create video playlist of %s.', playlist.url, lTags(playlist.uuid)) const byActor = playlist.OwnerAccount.Actor const audience = getAudience(byActor, playlist.privacy === VideoPlaylistPrivacy.PUBLIC) diff --git a/server/lib/activitypub/share.ts b/server/lib/activitypub/share.ts index 1f8a8f3c4..dde0c628e 100644 --- a/server/lib/activitypub/share.ts +++ b/server/lib/activitypub/share.ts @@ -1,15 +1,17 @@ -import { Transaction } from 'sequelize' -import { VideoShareModel } from '../../models/video/video-share' -import { sendUndoAnnounce, sendVideoAnnounce } from './send' -import { getLocalVideoAnnounceActivityPubUrl } from './url' import * as Bluebird from 'bluebird' +import { Transaction } from 'sequelize' +import { getServerActor } from '@server/models/application/application' +import { checkUrlsSameHost, getAPId } from '../../helpers/activitypub' +import { logger, loggerTagsFactory } from '../../helpers/logger' import { doRequest } from '../../helpers/requests' -import { getOrCreateActorAndServerAndModel } from './actor' -import { logger } from '../../helpers/logger' import { CRAWL_REQUEST_CONCURRENCY } from '../../initializers/constants' -import { checkUrlsSameHost, getAPId } from '../../helpers/activitypub' +import { VideoShareModel } from '../../models/video/video-share' import { MChannelActorLight, MVideo, MVideoAccountLight, MVideoId } from '../../types/models/video' -import { getServerActor } from '@server/models/application/application' +import { getOrCreateActorAndServerAndModel } from './actor' +import { sendUndoAnnounce, sendVideoAnnounce } from './send' +import { getLocalVideoAnnounceActivityPubUrl } from './url' + +const lTags = loggerTagsFactory('share') async function shareVideoByServerAndChannel (video: MVideoAccountLight, t: Transaction) { if (!video.hasPrivacyForFederation()) return undefined @@ -25,7 +27,10 @@ async function changeVideoChannelShare ( oldVideoChannel: MChannelActorLight, t: Transaction ) { - logger.info('Updating video channel of video %s: %s -> %s.', video.uuid, oldVideoChannel.name, video.VideoChannel.name) + logger.info( + 'Updating video channel of video %s: %s -> %s.', video.uuid, oldVideoChannel.name, video.VideoChannel.name, + lTags(video.uuid) + ) await undoShareByVideoChannel(video, oldVideoChannel, t) -- cgit v1.2.3