debian-mirror-gitlab/lib/gitlab/ci/artifacts/logger.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

65 lines
1.8 KiB
Ruby
Raw Normal View History

2022-08-27 11:52:29 +05:30
# frozen_string_literal: true
module Gitlab
module Ci
module Artifacts
module Logger
def log_artifacts_filesize(artifact_file)
return if artifact_file.nil?
unless artifact_file.is_a?(::Ci::Artifactable)
raise ArgumentError, "unknown artifact file class `#{artifact_file.class}`"
end
::Gitlab::ApplicationContext.push(artifact: artifact_file)
end
def log_artifacts_context(job)
::Gitlab::ApplicationContext.push(
namespace: job&.project&.namespace,
project: job&.project,
job: job
)
end
def log_build_dependencies(size:, count: 0)
::Gitlab::ApplicationContext.push(
artifacts_dependencies_size: size,
artifacts_dependencies_count: count
)
end
def self.log_created(artifact)
payload = Gitlab::ApplicationContext.current.merge(
message: 'Artifact created',
job_artifact_id: artifact.id,
size: artifact.size,
type: artifact.file_type,
build_id: artifact.job_id,
project_id: artifact.project_id
)
Gitlab::AppLogger.info(payload)
end
def self.log_deleted(job_artifacts, method)
Array(job_artifacts).each do |artifact|
payload = Gitlab::ApplicationContext.current.merge(
message: 'Artifact deleted',
job_artifact_id: artifact.id,
expire_at: artifact.expire_at,
size: artifact.size,
type: artifact.file_type,
build_id: artifact.job_id,
project_id: artifact.project_id,
method: method
)
Gitlab::AppLogger.info(payload)
end
end
end
end
end
end