mirror of
https://github.com/imgfloat/server.git
synced 2026-05-08 10:19:35 +00:00
refactor: standardize logger field name to LOG across all production classes
This commit is contained in:
@@ -14,7 +14,7 @@ public class SchemaMigration implements ApplicationRunner {
|
|||||||
|
|
||||||
// TODO: Code smell Runtime schema migration logic duplicates Flyway responsibilities and is difficult to reason about/test.
|
// TODO: Code smell Runtime schema migration logic duplicates Flyway responsibilities and is difficult to reason about/test.
|
||||||
|
|
||||||
private static final Logger logger = LoggerFactory.getLogger(SchemaMigration.class);
|
private static final Logger LOG = LoggerFactory.getLogger(SchemaMigration.class);
|
||||||
|
|
||||||
private final JdbcTemplate jdbcTemplate;
|
private final JdbcTemplate jdbcTemplate;
|
||||||
|
|
||||||
@@ -46,9 +46,9 @@ public class SchemaMigration implements ApplicationRunner {
|
|||||||
END;
|
END;
|
||||||
"""
|
"""
|
||||||
);
|
);
|
||||||
logger.info("Ensured SPRING_SESSION_ATTRIBUTES upsert trigger exists");
|
LOG.info("Ensured SPRING_SESSION_ATTRIBUTES upsert trigger exists");
|
||||||
} catch (DataAccessException ex) {
|
} catch (DataAccessException ex) {
|
||||||
logger.warn("Unable to ensure SPRING_SESSION_ATTRIBUTES upsert trigger", ex);
|
LOG.warn("Unable to ensure SPRING_SESSION_ATTRIBUTES upsert trigger", ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -57,7 +57,7 @@ public class SchemaMigration implements ApplicationRunner {
|
|||||||
try {
|
try {
|
||||||
columns = jdbcTemplate.query("PRAGMA table_info(channels)", (rs, rowNum) -> rs.getString("name"));
|
columns = jdbcTemplate.query("PRAGMA table_info(channels)", (rs, rowNum) -> rs.getString("name"));
|
||||||
} catch (DataAccessException ex) {
|
} catch (DataAccessException ex) {
|
||||||
logger.warn("Unable to inspect channels table for canvas columns", ex);
|
LOG.warn("Unable to inspect channels table for canvas columns", ex);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -76,7 +76,7 @@ public class SchemaMigration implements ApplicationRunner {
|
|||||||
try {
|
try {
|
||||||
columns = jdbcTemplate.query("PRAGMA table_info(assets)", (rs, rowNum) -> rs.getString("name"));
|
columns = jdbcTemplate.query("PRAGMA table_info(assets)", (rs, rowNum) -> rs.getString("name"));
|
||||||
} catch (DataAccessException ex) {
|
} catch (DataAccessException ex) {
|
||||||
logger.warn("Unable to inspect assets table for asset columns", ex);
|
LOG.warn("Unable to inspect assets table for asset columns", ex);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -169,7 +169,7 @@ public class SchemaMigration implements ApplicationRunner {
|
|||||||
ensureScriptAssetColumns();
|
ensureScriptAssetColumns();
|
||||||
backfillAssetTypes(assetColumns);
|
backfillAssetTypes(assetColumns);
|
||||||
} catch (DataAccessException ex) {
|
} catch (DataAccessException ex) {
|
||||||
logger.warn("Unable to ensure asset type tables", ex);
|
LOG.warn("Unable to ensure asset type tables", ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -185,7 +185,7 @@ public class SchemaMigration implements ApplicationRunner {
|
|||||||
"""
|
"""
|
||||||
);
|
);
|
||||||
} catch (DataAccessException ex) {
|
} catch (DataAccessException ex) {
|
||||||
logger.warn("Unable to ensure marketplace script hearts table", ex);
|
LOG.warn("Unable to ensure marketplace script hearts table", ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -197,7 +197,7 @@ public class SchemaMigration implements ApplicationRunner {
|
|||||||
attachmentColumns =
|
attachmentColumns =
|
||||||
jdbcTemplate.query("PRAGMA table_info(script_asset_attachments)", (rs, rowNum) -> rs.getString("name"));
|
jdbcTemplate.query("PRAGMA table_info(script_asset_attachments)", (rs, rowNum) -> rs.getString("name"));
|
||||||
} catch (DataAccessException ex) {
|
} catch (DataAccessException ex) {
|
||||||
logger.warn("Unable to inspect script asset tables", ex);
|
LOG.warn("Unable to inspect script asset tables", ex);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -236,7 +236,7 @@ public class SchemaMigration implements ApplicationRunner {
|
|||||||
);
|
);
|
||||||
jdbcTemplate.execute("UPDATE script_asset_attachments SET file_id = id WHERE file_id IS NULL");
|
jdbcTemplate.execute("UPDATE script_asset_attachments SET file_id = id WHERE file_id IS NULL");
|
||||||
} catch (DataAccessException ex) {
|
} catch (DataAccessException ex) {
|
||||||
logger.warn("Unable to backfill script asset files", ex);
|
LOG.warn("Unable to backfill script asset files", ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -295,7 +295,7 @@ public class SchemaMigration implements ApplicationRunner {
|
|||||||
"""
|
"""
|
||||||
);
|
);
|
||||||
} catch (DataAccessException ex) {
|
} catch (DataAccessException ex) {
|
||||||
logger.warn("Unable to backfill asset type tables", ex);
|
LOG.warn("Unable to backfill asset type tables", ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -326,9 +326,9 @@ public class SchemaMigration implements ApplicationRunner {
|
|||||||
columnName +
|
columnName +
|
||||||
" IS NULL"
|
" IS NULL"
|
||||||
);
|
);
|
||||||
logger.info("Added missing column '{}' to {} table", columnName, tableName);
|
LOG.info("Added missing column '{}' to {} table", columnName, tableName);
|
||||||
} catch (DataAccessException ex) {
|
} catch (DataAccessException ex) {
|
||||||
logger.warn("Failed to add column '{}' to {} table", columnName, tableName, ex);
|
LOG.warn("Failed to add column '{}' to {} table", columnName, tableName, ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -350,9 +350,9 @@ public class SchemaMigration implements ApplicationRunner {
|
|||||||
)
|
)
|
||||||
"""
|
"""
|
||||||
);
|
);
|
||||||
logger.info("Ensured oauth2_authorized_client table exists");
|
LOG.info("Ensured oauth2_authorized_client table exists");
|
||||||
} catch (DataAccessException ex) {
|
} catch (DataAccessException ex) {
|
||||||
logger.warn("Unable to ensure oauth2_authorized_client table", ex);
|
LOG.warn("Unable to ensure oauth2_authorized_client table", ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -394,10 +394,10 @@ public class SchemaMigration implements ApplicationRunner {
|
|||||||
" IS NOT NULL"
|
" IS NOT NULL"
|
||||||
);
|
);
|
||||||
if (updated > 0) {
|
if (updated > 0) {
|
||||||
logger.info("Normalized {} rows in oauth2_authorized_client.{}", updated, column);
|
LOG.info("Normalized {} rows in oauth2_authorized_client.{}", updated, column);
|
||||||
}
|
}
|
||||||
} catch (DataAccessException ex) {
|
} catch (DataAccessException ex) {
|
||||||
logger.warn("Unable to normalize oauth2_authorized_client.{} timestamps", column, ex);
|
LOG.warn("Unable to normalize oauth2_authorized_client.{} timestamps", column, ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import org.springframework.util.unit.DataSize;
|
|||||||
@Component
|
@Component
|
||||||
public class SystemEnvironmentValidator {
|
public class SystemEnvironmentValidator {
|
||||||
|
|
||||||
private static final Logger log = LoggerFactory.getLogger(SystemEnvironmentValidator.class);
|
private static final Logger LOG = LoggerFactory.getLogger(SystemEnvironmentValidator.class);
|
||||||
|
|
||||||
private final Environment environment;
|
private final Environment environment;
|
||||||
|
|
||||||
@@ -63,7 +63,7 @@ public class SystemEnvironmentValidator {
|
|||||||
environment.getProperty("org.springframework.boot.test.context.SpringBootTestContextBootstrapper")
|
environment.getProperty("org.springframework.boot.test.context.SpringBootTestContextBootstrapper")
|
||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
log.info("Skipping environment validation in test context");
|
LOG.info("Skipping environment validation in test context");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -88,19 +88,19 @@ public class SystemEnvironmentValidator {
|
|||||||
throw new IllegalStateException("Missing or invalid environment variables:\n" + missing);
|
throw new IllegalStateException("Missing or invalid environment variables:\n" + missing);
|
||||||
}
|
}
|
||||||
|
|
||||||
log.info("Environment validation successful:");
|
LOG.info("Environment validation successful:");
|
||||||
log.info(" - TWITCH_CLIENT_ID: {}", redact(twitchClientId));
|
LOG.info(" - TWITCH_CLIENT_ID: {}", redact(twitchClientId));
|
||||||
log.info(" - TWITCH_CLIENT_SECRET: {}", redact(twitchClientSecret));
|
LOG.info(" - TWITCH_CLIENT_SECRET: {}", redact(twitchClientSecret));
|
||||||
log.info(" - SPRING_SERVLET_MULTIPART_MAX_FILE_SIZE: {} ({} bytes)", springMaxFileSize, maxUploadBytes);
|
LOG.info(" - SPRING_SERVLET_MULTIPART_MAX_FILE_SIZE: {} ({} bytes)", springMaxFileSize, maxUploadBytes);
|
||||||
log.info(" - SPRING_SERVLET_MULTIPART_MAX_REQUEST_SIZE: {} ({} bytes)", springMaxRequestSize, maxRequestBytes);
|
LOG.info(" - SPRING_SERVLET_MULTIPART_MAX_REQUEST_SIZE: {} ({} bytes)", springMaxRequestSize, maxRequestBytes);
|
||||||
log.info(" - IMGFLOAT_DB_PATH: {}", dbPath);
|
LOG.info(" - IMGFLOAT_DB_PATH: {}", dbPath);
|
||||||
log.info(" - IMGFLOAT_AUDIT_DB_PATH: {}", auditDbPath);
|
LOG.info(" - IMGFLOAT_AUDIT_DB_PATH: {}", auditDbPath);
|
||||||
log.info(" - IMGFLOAT_INITIAL_TWITCH_USERNAME_SYSADMIN: {}", initialSysadmin);
|
LOG.info(" - IMGFLOAT_INITIAL_TWITCH_USERNAME_SYSADMIN: {}", initialSysadmin);
|
||||||
log.info(" - IMGFLOAT_ASSETS_PATH: {}", assetsPath);
|
LOG.info(" - IMGFLOAT_ASSETS_PATH: {}", assetsPath);
|
||||||
log.info(" - IMGFLOAT_PREVIEWS_PATH: {}", previewsPath);
|
LOG.info(" - IMGFLOAT_PREVIEWS_PATH: {}", previewsPath);
|
||||||
log.info(" - IMGFLOAT_GITHUB_CLIENT_OWNER: {}", githubClientOwner);
|
LOG.info(" - IMGFLOAT_GITHUB_CLIENT_OWNER: {}", githubClientOwner);
|
||||||
log.info(" - IMGFLOAT_GITHUB_CLIENT_REPO: {}", githubClientRepo);
|
LOG.info(" - IMGFLOAT_GITHUB_CLIENT_REPO: {}", githubClientRepo);
|
||||||
log.info(" - IMGFLOAT_GITHUB_CLIENT_VERSION: {}", githubClientVersion);
|
LOG.info(" - IMGFLOAT_GITHUB_CLIENT_VERSION: {}", githubClientVersion);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkString(String value, String name, StringBuilder missing) {
|
private void checkString(String value, String name, StringBuilder missing) {
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ import org.springframework.transaction.annotation.Transactional;
|
|||||||
@Service
|
@Service
|
||||||
public class AssetCleanupService {
|
public class AssetCleanupService {
|
||||||
|
|
||||||
private static final Logger logger = LoggerFactory.getLogger(AssetCleanupService.class);
|
private static final Logger LOG = LoggerFactory.getLogger(AssetCleanupService.class);
|
||||||
|
|
||||||
private final AssetRepository assetRepository;
|
private final AssetRepository assetRepository;
|
||||||
private final AssetStorageService assetStorageService;
|
private final AssetStorageService assetStorageService;
|
||||||
@@ -41,7 +41,7 @@ public class AssetCleanupService {
|
|||||||
@EventListener(ApplicationReadyEvent.class)
|
@EventListener(ApplicationReadyEvent.class)
|
||||||
@Transactional(readOnly = true)
|
@Transactional(readOnly = true)
|
||||||
public void cleanup() {
|
public void cleanup() {
|
||||||
logger.info("Collecting referenced assets");
|
LOG.info("Collecting referenced assets");
|
||||||
|
|
||||||
Set<String> referencedIds = assetRepository
|
Set<String> referencedIds = assetRepository
|
||||||
.findAll()
|
.findAll()
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ import org.springframework.stereotype.Service;
|
|||||||
@Service
|
@Service
|
||||||
public class AssetStorageService {
|
public class AssetStorageService {
|
||||||
|
|
||||||
private static final Logger logger = LoggerFactory.getLogger(AssetStorageService.class);
|
private static final Logger LOG = LoggerFactory.getLogger(AssetStorageService.class);
|
||||||
private static final String DEFAULT_PREVIEW_MEDIA_TYPE = "image/png";
|
private static final String DEFAULT_PREVIEW_MEDIA_TYPE = "image/png";
|
||||||
|
|
||||||
private final Path assetRoot;
|
private final Path assetRoot;
|
||||||
@@ -57,7 +57,7 @@ public class AssetStorageService {
|
|||||||
StandardOpenOption.TRUNCATE_EXISTING,
|
StandardOpenOption.TRUNCATE_EXISTING,
|
||||||
StandardOpenOption.WRITE
|
StandardOpenOption.WRITE
|
||||||
);
|
);
|
||||||
logger.info("Wrote asset to {}", file);
|
LOG.info("Wrote asset to {}", file);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void storePreview(String broadcaster, String assetId, byte[] previewBytes) throws IOException {
|
public void storePreview(String broadcaster, String assetId, byte[] previewBytes) throws IOException {
|
||||||
@@ -73,7 +73,7 @@ public class AssetStorageService {
|
|||||||
StandardOpenOption.TRUNCATE_EXISTING,
|
StandardOpenOption.TRUNCATE_EXISTING,
|
||||||
StandardOpenOption.WRITE
|
StandardOpenOption.WRITE
|
||||||
);
|
);
|
||||||
logger.info("Wrote asset preview to {}", file);
|
LOG.info("Wrote asset preview to {}", file);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Optional<AssetContent> loadAssetFile(String broadcaster, String assetId, String mediaType) {
|
public Optional<AssetContent> loadAssetFile(String broadcaster, String assetId, String mediaType) {
|
||||||
@@ -85,7 +85,7 @@ public class AssetStorageService {
|
|||||||
byte[] bytes = Files.readAllBytes(file);
|
byte[] bytes = Files.readAllBytes(file);
|
||||||
return Optional.of(new AssetContent(bytes, mediaType));
|
return Optional.of(new AssetContent(bytes, mediaType));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.warn("Failed to load asset {}", assetId, e);
|
LOG.warn("Failed to load asset {}", assetId, e);
|
||||||
return Optional.empty();
|
return Optional.empty();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -98,7 +98,7 @@ public class AssetStorageService {
|
|||||||
byte[] bytes = Files.readAllBytes(file);
|
byte[] bytes = Files.readAllBytes(file);
|
||||||
return Optional.of(new AssetContent(bytes, DEFAULT_PREVIEW_MEDIA_TYPE));
|
return Optional.of(new AssetContent(bytes, DEFAULT_PREVIEW_MEDIA_TYPE));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.warn("Failed to load preview {}", assetId, e);
|
LOG.warn("Failed to load preview {}", assetId, e);
|
||||||
return Optional.empty();
|
return Optional.empty();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -126,7 +126,7 @@ public class AssetStorageService {
|
|||||||
Files.deleteIfExists(previewPath(broadcaster, assetId));
|
Files.deleteIfExists(previewPath(broadcaster, assetId));
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.warn("Failed to delete asset {}", assetId, e);
|
LOG.warn("Failed to delete asset {}", assetId, e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -146,13 +146,13 @@ public class AssetStorageService {
|
|||||||
.forEach((p) -> {
|
.forEach((p) -> {
|
||||||
try {
|
try {
|
||||||
Files.delete(p);
|
Files.delete(p);
|
||||||
logger.warn("Deleted orphan file {}", p);
|
LOG.warn("Deleted orphan file {}", p);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
logger.error("Failed to delete {}", p, e);
|
LOG.error("Failed to delete {}", p, e);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
logger.error("Failed to walk {}", root, e);
|
LOG.error("Failed to walk {}", root, e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ import org.springframework.web.server.ResponseStatusException;
|
|||||||
@Service
|
@Service
|
||||||
public class ChannelDirectoryService {
|
public class ChannelDirectoryService {
|
||||||
|
|
||||||
private static final Logger logger = LoggerFactory.getLogger(ChannelDirectoryService.class);
|
private static final Logger LOG = LoggerFactory.getLogger(ChannelDirectoryService.class);
|
||||||
private static final Pattern SAFE_FILENAME = Pattern.compile("[^a-zA-Z0-9._ -]");
|
private static final Pattern SAFE_FILENAME = Pattern.compile("[^a-zA-Z0-9._ -]");
|
||||||
private static final String DEFAULT_CODE_MEDIA_TYPE = "application/javascript";
|
private static final String DEFAULT_CODE_MEDIA_TYPE = "application/javascript";
|
||||||
private static final EnumSet<AssetType> VISUAL_ASSET_TYPES = EnumSet.of(
|
private static final EnumSet<AssetType> VISUAL_ASSET_TYPES = EnumSet.of(
|
||||||
@@ -494,7 +494,7 @@ public class ChannelDirectoryService {
|
|||||||
try {
|
try {
|
||||||
sourceScript = scriptAssetRepository.findById(scriptId).filter(ScriptAsset::isPublic).orElse(null);
|
sourceScript = scriptAssetRepository.findById(scriptId).filter(ScriptAsset::isPublic).orElse(null);
|
||||||
} catch (DataAccessException ex) {
|
} catch (DataAccessException ex) {
|
||||||
logger.warn("Unable to import marketplace script {}", scriptId, ex);
|
LOG.warn("Unable to import marketplace script {}", scriptId, ex);
|
||||||
return Optional.empty();
|
return Optional.empty();
|
||||||
}
|
}
|
||||||
Asset sourceAsset = sourceScript == null ? null : assetRepository.findById(scriptId).orElse(null);
|
Asset sourceAsset = sourceScript == null ? null : assetRepository.findById(scriptId).orElse(null);
|
||||||
@@ -660,7 +660,7 @@ public class ChannelDirectoryService {
|
|||||||
try {
|
try {
|
||||||
return Optional.of(Files.readAllBytes(path));
|
return Optional.of(Files.readAllBytes(path));
|
||||||
} catch (IOException ex) {
|
} catch (IOException ex) {
|
||||||
logger.warn("Failed to read marketplace attachment {}", path, ex);
|
LOG.warn("Failed to read marketplace attachment {}", path, ex);
|
||||||
return Optional.empty();
|
return Optional.empty();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ public class MarketplaceScriptSeedLoader {
|
|||||||
|
|
||||||
// TODO: Code smell Large parser/loader with many branching paths; consider decomposing into smaller collaborators.
|
// TODO: Code smell Large parser/loader with many branching paths; consider decomposing into smaller collaborators.
|
||||||
|
|
||||||
private static final Logger logger = LoggerFactory.getLogger(MarketplaceScriptSeedLoader.class);
|
private static final Logger LOG = LoggerFactory.getLogger(MarketplaceScriptSeedLoader.class);
|
||||||
private static final String METADATA_FILENAME = "metadata.json";
|
private static final String METADATA_FILENAME = "metadata.json";
|
||||||
private static final String SOURCE_FILENAME = "source.js";
|
private static final String SOURCE_FILENAME = "source.js";
|
||||||
private static final String LOGO_FILENAME = "logo.png";
|
private static final String LOGO_FILENAME = "logo.png";
|
||||||
@@ -127,7 +127,7 @@ public class MarketplaceScriptSeedLoader {
|
|||||||
return List.of();
|
return List.of();
|
||||||
}
|
}
|
||||||
if (!Files.isDirectory(rootPath)) {
|
if (!Files.isDirectory(rootPath)) {
|
||||||
logger.warn("Marketplace script path {} is not a directory", rootPath);
|
LOG.warn("Marketplace script path {} is not a directory", rootPath);
|
||||||
return List.of();
|
return List.of();
|
||||||
}
|
}
|
||||||
List<SeedScript> loaded = new ArrayList<>();
|
List<SeedScript> loaded = new ArrayList<>();
|
||||||
@@ -139,7 +139,7 @@ public class MarketplaceScriptSeedLoader {
|
|||||||
loadScriptDirectory(scriptDir).ifPresent(loaded::add);
|
loadScriptDirectory(scriptDir).ifPresent(loaded::add);
|
||||||
}
|
}
|
||||||
} catch (IOException ex) {
|
} catch (IOException ex) {
|
||||||
logger.warn("Failed to read marketplace script directory {}", rootPath, ex);
|
LOG.warn("Failed to read marketplace script directory {}", rootPath, ex);
|
||||||
}
|
}
|
||||||
return List.copyOf(loaded);
|
return List.copyOf(loaded);
|
||||||
}
|
}
|
||||||
@@ -147,11 +147,11 @@ public class MarketplaceScriptSeedLoader {
|
|||||||
private Optional<SeedScript> loadScriptDirectory(Path scriptDir) {
|
private Optional<SeedScript> loadScriptDirectory(Path scriptDir) {
|
||||||
ScriptSeedMetadata metadata = ScriptSeedMetadata.read(scriptDir.resolve(METADATA_FILENAME));
|
ScriptSeedMetadata metadata = ScriptSeedMetadata.read(scriptDir.resolve(METADATA_FILENAME));
|
||||||
if (metadata == null) {
|
if (metadata == null) {
|
||||||
logger.warn("Skipping marketplace script {}, missing {}", scriptDir, METADATA_FILENAME);
|
LOG.warn("Skipping marketplace script {}, missing {}", scriptDir, METADATA_FILENAME);
|
||||||
return Optional.empty();
|
return Optional.empty();
|
||||||
}
|
}
|
||||||
if (metadata.name() == null || metadata.name().isBlank()) {
|
if (metadata.name() == null || metadata.name().isBlank()) {
|
||||||
logger.warn("Skipping marketplace script {}, missing name", scriptDir);
|
LOG.warn("Skipping marketplace script {}, missing name", scriptDir);
|
||||||
return Optional.empty();
|
return Optional.empty();
|
||||||
}
|
}
|
||||||
String sourceMediaType = detectMediaType(scriptDir.resolve(SOURCE_FILENAME), DEFAULT_SOURCE_MEDIA_TYPE);
|
String sourceMediaType = detectMediaType(scriptDir.resolve(SOURCE_FILENAME), DEFAULT_SOURCE_MEDIA_TYPE);
|
||||||
@@ -161,7 +161,7 @@ public class MarketplaceScriptSeedLoader {
|
|||||||
Path sourcePath = resolveOptionalFile(scriptDir.resolve(SOURCE_FILENAME));
|
Path sourcePath = resolveOptionalFile(scriptDir.resolve(SOURCE_FILENAME));
|
||||||
Path logoPath = resolveOptionalFile(scriptDir.resolve(LOGO_FILENAME));
|
Path logoPath = resolveOptionalFile(scriptDir.resolve(LOGO_FILENAME));
|
||||||
if (sourcePath == null) {
|
if (sourcePath == null) {
|
||||||
logger.warn("Skipping marketplace script {}, missing {}", scriptDir, SOURCE_FILENAME);
|
LOG.warn("Skipping marketplace script {}, missing {}", scriptDir, SOURCE_FILENAME);
|
||||||
return Optional.empty();
|
return Optional.empty();
|
||||||
}
|
}
|
||||||
List<SeedAttachment> attachments = loadAttachments(scriptDir.resolve(ATTACHMENTS_DIR)).orElse(null);
|
List<SeedAttachment> attachments = loadAttachments(scriptDir.resolve(ATTACHMENTS_DIR)).orElse(null);
|
||||||
@@ -199,7 +199,7 @@ public class MarketplaceScriptSeedLoader {
|
|||||||
if (Files.isRegularFile(attachment)) {
|
if (Files.isRegularFile(attachment)) {
|
||||||
String name = attachment.getFileName().toString();
|
String name = attachment.getFileName().toString();
|
||||||
if (!seenNames.add(name)) {
|
if (!seenNames.add(name)) {
|
||||||
logger.warn("Duplicate marketplace attachment name {}", name);
|
LOG.warn("Duplicate marketplace attachment name {}", name);
|
||||||
return Optional.empty();
|
return Optional.empty();
|
||||||
}
|
}
|
||||||
String mediaType = detectAttachmentMediaType(attachment);
|
String mediaType = detectAttachmentMediaType(attachment);
|
||||||
@@ -214,7 +214,7 @@ public class MarketplaceScriptSeedLoader {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (IOException ex) {
|
} catch (IOException ex) {
|
||||||
logger.warn("Failed to read marketplace attachments in {}", attachmentsDir, ex);
|
LOG.warn("Failed to read marketplace attachments in {}", attachmentsDir, ex);
|
||||||
}
|
}
|
||||||
return Optional.of(List.copyOf(attachments));
|
return Optional.of(List.copyOf(attachments));
|
||||||
}
|
}
|
||||||
@@ -242,7 +242,7 @@ public class MarketplaceScriptSeedLoader {
|
|||||||
return mediaType;
|
return mediaType;
|
||||||
}
|
}
|
||||||
} catch (IOException ex) {
|
} catch (IOException ex) {
|
||||||
logger.warn("Failed to detect media type for {}", attachment, ex);
|
LOG.warn("Failed to detect media type for {}", attachment, ex);
|
||||||
}
|
}
|
||||||
String filename = attachment.getFileName().toString().toLowerCase(Locale.ROOT);
|
String filename = attachment.getFileName().toString().toLowerCase(Locale.ROOT);
|
||||||
int dot = filename.lastIndexOf('.');
|
int dot = filename.lastIndexOf('.');
|
||||||
@@ -299,7 +299,7 @@ public class MarketplaceScriptSeedLoader {
|
|||||||
try {
|
try {
|
||||||
return Optional.of(Files.readAllBytes(filePath));
|
return Optional.of(Files.readAllBytes(filePath));
|
||||||
} catch (IOException ex) {
|
} catch (IOException ex) {
|
||||||
logger.warn("Failed to read marketplace script asset {}", filePath, ex);
|
LOG.warn("Failed to read marketplace script asset {}", filePath, ex);
|
||||||
return Optional.empty();
|
return Optional.empty();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -313,7 +313,7 @@ public class MarketplaceScriptSeedLoader {
|
|||||||
String content = Files.readString(path);
|
String content = Files.readString(path);
|
||||||
return JsonSupport.read(content);
|
return JsonSupport.read(content);
|
||||||
} catch (IOException ex) {
|
} catch (IOException ex) {
|
||||||
logger.warn("Failed to read marketplace metadata {}", path, ex);
|
LOG.warn("Failed to read marketplace metadata {}", path, ex);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -347,7 +347,7 @@ public class MarketplaceScriptSeedLoader {
|
|||||||
String mediaType = Files.probeContentType(path);
|
String mediaType = Files.probeContentType(path);
|
||||||
return mediaType == null ? fallback : mediaType;
|
return mediaType == null ? fallback : mediaType;
|
||||||
} catch (IOException ex) {
|
} catch (IOException ex) {
|
||||||
logger.warn("Failed to detect media type for {}", path, ex);
|
LOG.warn("Failed to detect media type for {}", path, ex);
|
||||||
return fallback;
|
return fallback;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ import org.springframework.stereotype.Service;
|
|||||||
@Service
|
@Service
|
||||||
public class SettingsService {
|
public class SettingsService {
|
||||||
|
|
||||||
private static final Logger logger = LoggerFactory.getLogger(SettingsService.class);
|
private static final Logger LOG = LoggerFactory.getLogger(SettingsService.class);
|
||||||
|
|
||||||
private final SettingsRepository repo;
|
private final SettingsRepository repo;
|
||||||
private final VisualAssetRepository visualAssetRepository;
|
private final VisualAssetRepository visualAssetRepository;
|
||||||
@@ -68,9 +68,9 @@ public class SettingsService {
|
|||||||
|
|
||||||
public void logSettings(String msg, Settings settings) {
|
public void logSettings(String msg, Settings settings) {
|
||||||
try {
|
try {
|
||||||
logger.info("{}:\n{}", msg, objectMapper.writerWithDefaultPrettyPrinter().writeValueAsString(settings));
|
LOG.info("{}:\n{}", msg, objectMapper.writerWithDefaultPrettyPrinter().writeValueAsString(settings));
|
||||||
} catch (JsonProcessingException e) {
|
} catch (JsonProcessingException e) {
|
||||||
logger.error("Failed to serialize settings", e);
|
LOG.error("Failed to serialize settings", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -136,7 +136,7 @@ public class SettingsService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!visualsToUpdate.isEmpty() || !audioToUpdate.isEmpty()) {
|
if (!visualsToUpdate.isEmpty() || !audioToUpdate.isEmpty()) {
|
||||||
logger.info(
|
LOG.info(
|
||||||
"Normalized {} visual assets and {} audio assets to new settings ranges",
|
"Normalized {} visual assets and {} audio assets to new settings ranges",
|
||||||
visualsToUpdate.size(),
|
visualsToUpdate.size(),
|
||||||
audioToUpdate.size()
|
audioToUpdate.size()
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ import org.springframework.transaction.annotation.Transactional;
|
|||||||
@Service
|
@Service
|
||||||
public class SystemAdministratorService {
|
public class SystemAdministratorService {
|
||||||
|
|
||||||
private static final Logger logger = LoggerFactory.getLogger(SystemAdministratorService.class);
|
private static final Logger LOG = LoggerFactory.getLogger(SystemAdministratorService.class);
|
||||||
|
|
||||||
private final SystemAdministratorRepository repo;
|
private final SystemAdministratorRepository repo;
|
||||||
private final Environment environment;
|
private final Environment environment;
|
||||||
@@ -41,7 +41,7 @@ public class SystemAdministratorService {
|
|||||||
environment.getProperty("org.springframework.boot.test.context.SpringBootTestContextBootstrapper")
|
environment.getProperty("org.springframework.boot.test.context.SpringBootTestContextBootstrapper")
|
||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
logger.info("Skipping system administrator bootstrap in test context");
|
LOG.info("Skipping system administrator bootstrap in test context");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -49,7 +49,7 @@ public class SystemAdministratorService {
|
|||||||
if (initialSysadmin != null) {
|
if (initialSysadmin != null) {
|
||||||
long deleted = repo.deleteByTwitchUsername(initialSysadmin);
|
long deleted = repo.deleteByTwitchUsername(initialSysadmin);
|
||||||
if (deleted > 0) {
|
if (deleted > 0) {
|
||||||
logger.info("Removed persisted initial system administrator '{}' to use environment value", initialSysadmin);
|
LOG.info("Removed persisted initial system administrator '{}' to use environment value", initialSysadmin);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -63,7 +63,7 @@ public class SystemAdministratorService {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.info("Using initial system administrator '{}' from environment", initialSysadmin);
|
LOG.info("Using initial system administrator '{}' from environment", initialSysadmin);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addSysadmin(String twitchUsername) {
|
public void addSysadmin(String twitchUsername) {
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ import org.springframework.stereotype.Service;
|
|||||||
@Service
|
@Service
|
||||||
public class FfmpegService {
|
public class FfmpegService {
|
||||||
|
|
||||||
private static final Logger logger = LoggerFactory.getLogger(FfmpegService.class);
|
private static final Logger LOG = LoggerFactory.getLogger(FfmpegService.class);
|
||||||
|
|
||||||
public Optional<VideoDimensions> extractVideoDimensions(byte[] bytes) {
|
public Optional<VideoDimensions> extractVideoDimensions(byte[] bytes) {
|
||||||
return Optional.ofNullable(withTempFile(bytes, ".bin", (input) -> {
|
return Optional.ofNullable(withTempFile(bytes, ".bin", (input) -> {
|
||||||
@@ -34,7 +34,7 @@ public class FfmpegService {
|
|||||||
);
|
);
|
||||||
ProcessResult result = run(command);
|
ProcessResult result = run(command);
|
||||||
if (result.exitCode() != 0) {
|
if (result.exitCode() != 0) {
|
||||||
logger.warn("ffprobe failed: {}", result.output());
|
LOG.warn("ffprobe failed: {}", result.output());
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
String output = result.output().trim();
|
String output = result.output().trim();
|
||||||
@@ -47,7 +47,7 @@ public class FfmpegService {
|
|||||||
int height = Integer.parseInt(parts[1].trim());
|
int height = Integer.parseInt(parts[1].trim());
|
||||||
return new VideoDimensions(width, height);
|
return new VideoDimensions(width, height);
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException e) {
|
||||||
logger.warn("Unable to parse ffprobe output: {}", output, e);
|
LOG.warn("Unable to parse ffprobe output: {}", output, e);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
@@ -75,7 +75,7 @@ public class FfmpegService {
|
|||||||
);
|
);
|
||||||
ProcessResult result = run(command);
|
ProcessResult result = run(command);
|
||||||
if (result.exitCode() != 0) {
|
if (result.exitCode() != 0) {
|
||||||
logger.warn("ffmpeg preview failed: {}", result.output());
|
LOG.warn("ffmpeg preview failed: {}", result.output());
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return Files.readAllBytes(output);
|
return Files.readAllBytes(output);
|
||||||
@@ -111,7 +111,7 @@ public class FfmpegService {
|
|||||||
);
|
);
|
||||||
ProcessResult result = run(command);
|
ProcessResult result = run(command);
|
||||||
if (result.exitCode() != 0) {
|
if (result.exitCode() != 0) {
|
||||||
logger.warn("ffmpeg transcode failed: {}", result.output());
|
LOG.warn("ffmpeg transcode failed: {}", result.output());
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return Files.readAllBytes(output);
|
return Files.readAllBytes(output);
|
||||||
@@ -139,7 +139,7 @@ public class FfmpegService {
|
|||||||
);
|
);
|
||||||
ProcessResult result = run(command);
|
ProcessResult result = run(command);
|
||||||
if (result.exitCode() != 0) {
|
if (result.exitCode() != 0) {
|
||||||
logger.warn("ffmpeg APNG transcode failed: {}", result.output());
|
LOG.warn("ffmpeg APNG transcode failed: {}", result.output());
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return Files.readAllBytes(output);
|
return Files.readAllBytes(output);
|
||||||
@@ -156,14 +156,14 @@ public class FfmpegService {
|
|||||||
Files.write(input, bytes);
|
Files.write(input, bytes);
|
||||||
return handler.handle(input);
|
return handler.handle(input);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
logger.warn("Unable to create temporary media file", e);
|
LOG.warn("Unable to create temporary media file", e);
|
||||||
return null;
|
return null;
|
||||||
} finally {
|
} finally {
|
||||||
if (input != null) {
|
if (input != null) {
|
||||||
try {
|
try {
|
||||||
Files.deleteIfExists(input);
|
Files.deleteIfExists(input);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
logger.warn("Unable to delete temporary file {}", input, e);
|
LOG.warn("Unable to delete temporary file {}", input, e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ import org.springframework.web.multipart.MultipartFile;
|
|||||||
@Service
|
@Service
|
||||||
public class MediaDetectionService {
|
public class MediaDetectionService {
|
||||||
|
|
||||||
private static final Logger logger = LoggerFactory.getLogger(MediaDetectionService.class);
|
private static final Logger LOG = LoggerFactory.getLogger(MediaDetectionService.class);
|
||||||
|
|
||||||
public Optional<String> detectAllowedMediaType(MultipartFile file, byte[] bytes) {
|
public Optional<String> detectAllowedMediaType(MultipartFile file, byte[] bytes) {
|
||||||
Optional<String> detected = detectMediaType(bytes)
|
Optional<String> detected = detectMediaType(bytes)
|
||||||
@@ -47,7 +47,7 @@ public class MediaDetectionService {
|
|||||||
return Optional.of(guessed);
|
return Optional.of(guessed);
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
logger.warn("Unable to detect content type from stream", e);
|
LOG.warn("Unable to detect content type from stream", e);
|
||||||
}
|
}
|
||||||
|
|
||||||
return Optional.empty();
|
return Optional.empty();
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import org.springframework.stereotype.Service;
|
|||||||
@Service
|
@Service
|
||||||
public class MediaOptimizationService {
|
public class MediaOptimizationService {
|
||||||
|
|
||||||
private static final Logger logger = LoggerFactory.getLogger(MediaOptimizationService.class);
|
private static final Logger LOG = LoggerFactory.getLogger(MediaOptimizationService.class);
|
||||||
private static final FfmpegService.VideoDimensions DEFAULT_VIDEO_DIMENSIONS = new FfmpegService.VideoDimensions(
|
private static final FfmpegService.VideoDimensions DEFAULT_VIDEO_DIMENSIONS = new FfmpegService.VideoDimensions(
|
||||||
640,
|
640,
|
||||||
360
|
360
|
||||||
@@ -87,7 +87,7 @@ public class MediaOptimizationService {
|
|||||||
.transcodeApngToGif(bytes)
|
.transcodeApngToGif(bytes)
|
||||||
.map(this::transcodeGifToVideo)
|
.map(this::transcodeGifToVideo)
|
||||||
.orElseGet(() -> {
|
.orElseGet(() -> {
|
||||||
logger.warn("Unable to transcode APNG to GIF via ffmpeg");
|
LOG.warn("Unable to transcode APNG to GIF via ffmpeg");
|
||||||
return null;
|
return null;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -103,7 +103,7 @@ public class MediaOptimizationService {
|
|||||||
return new OptimizedAsset(videoBytes, "video/webm", dimensions.width(), dimensions.height(), preview);
|
return new OptimizedAsset(videoBytes, "video/webm", dimensions.width(), dimensions.height(), preview);
|
||||||
})
|
})
|
||||||
.orElseGet(() -> {
|
.orElseGet(() -> {
|
||||||
logger.warn("Unable to transcode GIF to video via ffmpeg");
|
LOG.warn("Unable to transcode GIF to video via ffmpeg");
|
||||||
return null;
|
return null;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import org.springframework.stereotype.Service;
|
|||||||
@Service
|
@Service
|
||||||
public class MediaPreviewService {
|
public class MediaPreviewService {
|
||||||
|
|
||||||
private static final Logger logger = LoggerFactory.getLogger(MediaPreviewService.class);
|
private static final Logger LOG = LoggerFactory.getLogger(MediaPreviewService.class);
|
||||||
|
|
||||||
private final FfmpegService ffmpegService;
|
private final FfmpegService ffmpegService;
|
||||||
|
|
||||||
@@ -19,7 +19,7 @@ public class MediaPreviewService {
|
|||||||
return ffmpegService
|
return ffmpegService
|
||||||
.extractVideoPreview(bytes)
|
.extractVideoPreview(bytes)
|
||||||
.orElseGet(() -> {
|
.orElseGet(() -> {
|
||||||
logger.warn("Unable to capture video preview frame for {}", mediaType);
|
LOG.warn("Unable to capture video preview frame for {}", mediaType);
|
||||||
return null;
|
return null;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user