Archived
Replace SLF4J with BarnLogger and update documentation
- Replace SLF4J/logback with custom BarnLogger across all source files - BarnLogger is disabled by default for CLI commands, enabled for service - Fixes #30: debug logs no longer break JSON/XML CLI output - Add SpotBugs exclusions for BarnLogger false positives - Update docs: remove .deb and AUR references (no longer applicable) - Update docs: add Windows setup.exe installation instructions - Update docs: clarify auto-update only works with Homebrew Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
41126eeed4
commit
d95ac32739
44 files changed
+466
-1227
No files matched your search
@@ -12,9 +12,6 @@ import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import com.fasterxml.jackson.databind.DeserializationFeature;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
@@ -24,6 +21,7 @@ import com.samsonmedia.barn.ipc.IpcClient;
|
||||
import com.samsonmedia.barn.ipc.IpcException;
|
||||
import com.samsonmedia.barn.jobs.Job;
|
||||
import com.samsonmedia.barn.jobs.JobRepository;
|
||||
import com.samsonmedia.barn.logging.BarnLogger;
|
||||
import com.samsonmedia.barn.state.BarnDirectories;
|
||||
import com.samsonmedia.barn.state.JobState;
|
||||
import com.samsonmedia.barn.util.DurationParser;
|
||||
@@ -41,7 +39,7 @@ import picocli.CommandLine.Option;
|
||||
)
|
||||
public class CleanCommand extends BaseCommand {
|
||||
|
||||
private static final Logger LOG = LoggerFactory.getLogger(CleanCommand.class);
|
||||
private static final BarnLogger LOG = BarnLogger.getLogger(CleanCommand.class);
|
||||
|
||||
@Option(names = {"--all"}, description = "Remove all completed jobs regardless of age")
|
||||
private boolean all;
|
||||
|
||||
@@ -15,9 +15,6 @@ import java.util.Optional;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.fasterxml.jackson.databind.DeserializationFeature;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
|
||||
@@ -27,6 +24,7 @@ import com.samsonmedia.barn.ipc.IpcException;
|
||||
import com.samsonmedia.barn.jobs.Job;
|
||||
import com.samsonmedia.barn.jobs.JobManifest;
|
||||
import com.samsonmedia.barn.jobs.JobRepository;
|
||||
import com.samsonmedia.barn.logging.BarnLogger;
|
||||
import com.samsonmedia.barn.state.BarnDirectories;
|
||||
|
||||
import picocli.CommandLine.Command;
|
||||
@@ -43,7 +41,7 @@ import picocli.CommandLine.Parameters;
|
||||
)
|
||||
public class DescribeCommand extends BaseCommand {
|
||||
|
||||
private static final Logger LOG = LoggerFactory.getLogger(DescribeCommand.class);
|
||||
private static final BarnLogger LOG = BarnLogger.getLogger(DescribeCommand.class);
|
||||
private static final DateTimeFormatter DATE_FORMAT = DateTimeFormatter
|
||||
.ofPattern("yyyy-MM-dd HH:mm:ss")
|
||||
.withZone(ZoneId.systemDefault());
|
||||
|
||||
@@ -6,9 +6,6 @@ import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.fasterxml.jackson.databind.DeserializationFeature;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
|
||||
@@ -18,6 +15,7 @@ import com.samsonmedia.barn.ipc.IpcClient;
|
||||
import com.samsonmedia.barn.ipc.IpcException;
|
||||
import com.samsonmedia.barn.jobs.Job;
|
||||
import com.samsonmedia.barn.jobs.JobRepository;
|
||||
import com.samsonmedia.barn.logging.BarnLogger;
|
||||
import com.samsonmedia.barn.state.BarnDirectories;
|
||||
import com.samsonmedia.barn.state.JobState;
|
||||
|
||||
@@ -35,7 +33,7 @@ import picocli.CommandLine.Parameters;
|
||||
)
|
||||
public class KillCommand extends BaseCommand {
|
||||
|
||||
private static final Logger LOG = LoggerFactory.getLogger(KillCommand.class);
|
||||
private static final BarnLogger LOG = BarnLogger.getLogger(KillCommand.class);
|
||||
|
||||
@Parameters(index = "0", description = "Job ID")
|
||||
private String jobId;
|
||||
|
||||
@@ -7,9 +7,6 @@ import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.fasterxml.jackson.databind.DeserializationFeature;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
|
||||
@@ -19,6 +16,7 @@ import com.samsonmedia.barn.ipc.IpcClient;
|
||||
import com.samsonmedia.barn.ipc.IpcException;
|
||||
import com.samsonmedia.barn.jobs.Job;
|
||||
import com.samsonmedia.barn.jobs.JobRepository;
|
||||
import com.samsonmedia.barn.logging.BarnLogger;
|
||||
import com.samsonmedia.barn.state.BarnDirectories;
|
||||
|
||||
import picocli.CommandLine.Command;
|
||||
@@ -38,7 +36,7 @@ import picocli.CommandLine.Parameters;
|
||||
)
|
||||
public class RunCommand extends BaseCommand {
|
||||
|
||||
private static final Logger LOG = LoggerFactory.getLogger(RunCommand.class);
|
||||
private static final BarnLogger LOG = BarnLogger.getLogger(RunCommand.class);
|
||||
|
||||
@Option(names = {"--tag", "-t"}, description = "Tag for filtering jobs")
|
||||
private String tag;
|
||||
|
||||
@@ -4,11 +4,9 @@ import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.samsonmedia.barn.config.ConfigDefaults;
|
||||
import com.samsonmedia.barn.config.OperatingSystem;
|
||||
import com.samsonmedia.barn.logging.BarnLogger;
|
||||
import com.samsonmedia.barn.platform.linux.SystemdManager;
|
||||
import com.samsonmedia.barn.platform.macos.LaunchdManager;
|
||||
import com.samsonmedia.barn.platform.windows.WindowsServiceManager;
|
||||
@@ -33,7 +31,7 @@ import picocli.CommandLine.Option;
|
||||
)
|
||||
public class ServiceInstallCommand extends BaseCommand {
|
||||
|
||||
private static final Logger LOG = LoggerFactory.getLogger(ServiceInstallCommand.class);
|
||||
private static final BarnLogger LOG = BarnLogger.getLogger(ServiceInstallCommand.class);
|
||||
|
||||
@Option(names = {"--user"}, description = "Install as user service instead of system-wide")
|
||||
private boolean userService;
|
||||
|
||||
@@ -8,10 +8,8 @@ import java.nio.file.Path;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.samsonmedia.barn.config.ConfigDefaults;
|
||||
import com.samsonmedia.barn.logging.BarnLogger;
|
||||
|
||||
import picocli.CommandLine.Command;
|
||||
import picocli.CommandLine.Option;
|
||||
@@ -26,7 +24,7 @@ import picocli.CommandLine.Option;
|
||||
)
|
||||
public class ServiceLogsCommand extends BaseCommand {
|
||||
|
||||
private static final Logger LOG = LoggerFactory.getLogger(ServiceLogsCommand.class);
|
||||
private static final BarnLogger LOG = BarnLogger.getLogger(ServiceLogsCommand.class);
|
||||
private static final String LOG_FILE_NAME = "barn.log";
|
||||
|
||||
@Option(names = {"--follow", "-f"}, description = "Follow log output")
|
||||
|
||||
@@ -6,12 +6,10 @@ import java.nio.file.Path;
|
||||
import java.util.Locale;
|
||||
import java.util.Optional;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.samsonmedia.barn.config.ConfigDefaults;
|
||||
import com.samsonmedia.barn.ipc.IpcClient;
|
||||
import com.samsonmedia.barn.ipc.IpcException;
|
||||
import com.samsonmedia.barn.logging.BarnLogger;
|
||||
|
||||
import picocli.CommandLine.Command;
|
||||
import picocli.CommandLine.Option;
|
||||
@@ -26,7 +24,7 @@ import picocli.CommandLine.Option;
|
||||
)
|
||||
public class ServiceReloadCommand extends BaseCommand {
|
||||
|
||||
private static final Logger LOG = LoggerFactory.getLogger(ServiceReloadCommand.class);
|
||||
private static final BarnLogger LOG = BarnLogger.getLogger(ServiceReloadCommand.class);
|
||||
|
||||
@Option(names = {"--barn-dir"}, description = "Barn data directory", hidden = true)
|
||||
private Path barnDir;
|
||||
|
||||
@@ -5,11 +5,9 @@ import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.Optional;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.samsonmedia.barn.config.ConfigDefaults;
|
||||
import com.samsonmedia.barn.execution.ProcessUtils;
|
||||
import com.samsonmedia.barn.logging.BarnLogger;
|
||||
|
||||
import picocli.CommandLine.Command;
|
||||
import picocli.CommandLine.Option;
|
||||
@@ -24,7 +22,7 @@ import picocli.CommandLine.Option;
|
||||
)
|
||||
public class ServiceRestartCommand extends BaseCommand {
|
||||
|
||||
private static final Logger LOG = LoggerFactory.getLogger(ServiceRestartCommand.class);
|
||||
private static final BarnLogger LOG = BarnLogger.getLogger(ServiceRestartCommand.class);
|
||||
private static final long DEFAULT_WAIT_SECONDS = 30;
|
||||
|
||||
@Option(names = {"--force", "-f"}, description = "Force immediate restart")
|
||||
|
||||
@@ -5,12 +5,10 @@ import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.Optional;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.samsonmedia.barn.config.Config;
|
||||
import com.samsonmedia.barn.config.ConfigDefaults;
|
||||
import com.samsonmedia.barn.config.ConfigLoader;
|
||||
import com.samsonmedia.barn.logging.BarnLogger;
|
||||
import com.samsonmedia.barn.service.BarnService;
|
||||
|
||||
import picocli.CommandLine.Command;
|
||||
@@ -26,7 +24,7 @@ import picocli.CommandLine.Option;
|
||||
)
|
||||
public class ServiceStartCommand extends BaseCommand {
|
||||
|
||||
private static final Logger LOG = LoggerFactory.getLogger(ServiceStartCommand.class);
|
||||
private static final BarnLogger LOG = BarnLogger.getLogger(ServiceStartCommand.class);
|
||||
|
||||
@Option(names = {"--foreground", "-f"}, description = "Run in foreground (don't daemonize)")
|
||||
private boolean foreground;
|
||||
|
||||
@@ -11,14 +11,12 @@ import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.samsonmedia.barn.config.ConfigDefaults;
|
||||
import com.samsonmedia.barn.config.OperatingSystem;
|
||||
import com.samsonmedia.barn.ipc.IpcClient;
|
||||
import com.samsonmedia.barn.ipc.IpcException;
|
||||
import com.samsonmedia.barn.jobs.JobRepository;
|
||||
import com.samsonmedia.barn.logging.BarnLogger;
|
||||
import com.samsonmedia.barn.platform.linux.SystemdManager;
|
||||
import com.samsonmedia.barn.platform.macos.LaunchdManager;
|
||||
import com.samsonmedia.barn.platform.windows.WindowsServiceManager;
|
||||
@@ -38,7 +36,7 @@ import picocli.CommandLine.Option;
|
||||
)
|
||||
public class ServiceStatusCommand extends BaseCommand {
|
||||
|
||||
private static final Logger LOG = LoggerFactory.getLogger(ServiceStatusCommand.class);
|
||||
private static final BarnLogger LOG = BarnLogger.getLogger(ServiceStatusCommand.class);
|
||||
private static final DateTimeFormatter DATE_FORMAT = DateTimeFormatter
|
||||
.ofPattern("yyyy-MM-dd HH:mm:ss")
|
||||
.withZone(ZoneId.systemDefault());
|
||||
|
||||
@@ -5,11 +5,9 @@ import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.Optional;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.samsonmedia.barn.config.ConfigDefaults;
|
||||
import com.samsonmedia.barn.execution.ProcessUtils;
|
||||
import com.samsonmedia.barn.logging.BarnLogger;
|
||||
|
||||
import picocli.CommandLine.Command;
|
||||
import picocli.CommandLine.Option;
|
||||
@@ -24,7 +22,7 @@ import picocli.CommandLine.Option;
|
||||
)
|
||||
public class ServiceStopCommand extends BaseCommand {
|
||||
|
||||
private static final Logger LOG = LoggerFactory.getLogger(ServiceStopCommand.class);
|
||||
private static final BarnLogger LOG = BarnLogger.getLogger(ServiceStopCommand.class);
|
||||
private static final long DEFAULT_WAIT_SECONDS = 30;
|
||||
|
||||
@Option(names = {"--force", "-f"}, description = "Force immediate stop (SIGKILL)")
|
||||
|
||||
@@ -3,10 +3,8 @@ package com.samsonmedia.barn.cli;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.samsonmedia.barn.config.OperatingSystem;
|
||||
import com.samsonmedia.barn.logging.BarnLogger;
|
||||
import com.samsonmedia.barn.platform.linux.SystemdManager;
|
||||
import com.samsonmedia.barn.platform.macos.LaunchdManager;
|
||||
import com.samsonmedia.barn.platform.windows.WindowsServiceManager;
|
||||
@@ -31,7 +29,7 @@ import picocli.CommandLine.Option;
|
||||
)
|
||||
public class ServiceUninstallCommand extends BaseCommand {
|
||||
|
||||
private static final Logger LOG = LoggerFactory.getLogger(ServiceUninstallCommand.class);
|
||||
private static final BarnLogger LOG = BarnLogger.getLogger(ServiceUninstallCommand.class);
|
||||
|
||||
@Option(names = {"--user"}, description = "Uninstall user service instead of system-wide")
|
||||
private boolean userService;
|
||||
|
||||
@@ -12,9 +12,6 @@ import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import com.fasterxml.jackson.databind.DeserializationFeature;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
@@ -24,6 +21,7 @@ import com.samsonmedia.barn.ipc.IpcClient;
|
||||
import com.samsonmedia.barn.ipc.IpcException;
|
||||
import com.samsonmedia.barn.jobs.Job;
|
||||
import com.samsonmedia.barn.jobs.JobRepository;
|
||||
import com.samsonmedia.barn.logging.BarnLogger;
|
||||
import com.samsonmedia.barn.state.BarnDirectories;
|
||||
import com.samsonmedia.barn.state.JobState;
|
||||
|
||||
@@ -42,7 +40,7 @@ import picocli.CommandLine.Option;
|
||||
)
|
||||
public class StatusCommand extends BaseCommand {
|
||||
|
||||
private static final Logger LOG = LoggerFactory.getLogger(StatusCommand.class);
|
||||
private static final BarnLogger LOG = BarnLogger.getLogger(StatusCommand.class);
|
||||
private static final DateTimeFormatter DATE_FORMAT = DateTimeFormatter
|
||||
.ofPattern("yyyy-MM-dd HH:mm:ss")
|
||||
.withZone(ZoneId.systemDefault());
|
||||
|
||||
@@ -13,14 +13,12 @@ import java.util.Optional;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.samsonmedia.barn.config.ConfigDefaults;
|
||||
import com.samsonmedia.barn.ipc.IpcClient;
|
||||
import com.samsonmedia.barn.ipc.IpcException;
|
||||
import com.samsonmedia.barn.jobs.Job;
|
||||
import com.samsonmedia.barn.jobs.JobRepository;
|
||||
import com.samsonmedia.barn.logging.BarnLogger;
|
||||
import com.samsonmedia.barn.monitoring.UsageLogger;
|
||||
import com.samsonmedia.barn.monitoring.UsageRecord;
|
||||
import com.samsonmedia.barn.state.BarnDirectories;
|
||||
@@ -39,7 +37,7 @@ import picocli.CommandLine.Parameters;
|
||||
)
|
||||
public class UsageCommand extends BaseCommand {
|
||||
|
||||
private static final Logger LOG = LoggerFactory.getLogger(UsageCommand.class);
|
||||
private static final BarnLogger LOG = BarnLogger.getLogger(UsageCommand.class);
|
||||
private static final DateTimeFormatter DATE_FORMAT = DateTimeFormatter
|
||||
.ofPattern("yyyy-MM-dd HH:mm:ss")
|
||||
.withZone(ZoneId.systemDefault());
|
||||
|
||||
@@ -12,8 +12,7 @@ import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.function.Function;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import com.samsonmedia.barn.logging.BarnLogger;
|
||||
|
||||
/**
|
||||
* Loads and validates Barn configuration from files and environment variables.
|
||||
@@ -29,7 +28,7 @@ import org.slf4j.LoggerFactory;
|
||||
*/
|
||||
public final class ConfigLoader {
|
||||
|
||||
private static final Logger LOG = LoggerFactory.getLogger(ConfigLoader.class);
|
||||
private static final BarnLogger LOG = BarnLogger.getLogger(ConfigLoader.class);
|
||||
private static final String ENV_PREFIX = "BARN_";
|
||||
|
||||
private final Map<String, String> environment;
|
||||
|
||||
@@ -6,13 +6,11 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.samsonmedia.barn.config.Config;
|
||||
import com.samsonmedia.barn.jobs.Job;
|
||||
import com.samsonmedia.barn.jobs.JobRepository;
|
||||
import com.samsonmedia.barn.jobs.RetryCalculator;
|
||||
import com.samsonmedia.barn.logging.BarnLogger;
|
||||
import com.samsonmedia.barn.state.BarnDirectories;
|
||||
import com.samsonmedia.barn.state.JobState;
|
||||
|
||||
@@ -31,7 +29,7 @@ import com.samsonmedia.barn.state.JobState;
|
||||
*/
|
||||
public class CrashRecovery {
|
||||
|
||||
private static final Logger LOG = LoggerFactory.getLogger(CrashRecovery.class);
|
||||
private static final BarnLogger LOG = BarnLogger.getLogger(CrashRecovery.class);
|
||||
private static final String KILLED_ERROR = "Process killed - daemon restarted";
|
||||
|
||||
private final JobRepository repository;
|
||||
|
||||
@@ -7,13 +7,11 @@ import java.time.Instant;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.samsonmedia.barn.config.JobsConfig;
|
||||
import com.samsonmedia.barn.jobs.Job;
|
||||
import com.samsonmedia.barn.jobs.JobRepository;
|
||||
import com.samsonmedia.barn.jobs.RetryCalculator;
|
||||
import com.samsonmedia.barn.logging.BarnLogger;
|
||||
import com.samsonmedia.barn.monitoring.UsageMonitor;
|
||||
import com.samsonmedia.barn.state.BarnDirectories;
|
||||
|
||||
@@ -32,7 +30,7 @@ import com.samsonmedia.barn.state.BarnDirectories;
|
||||
*/
|
||||
public class JobRunner {
|
||||
|
||||
private static final Logger LOG = LoggerFactory.getLogger(JobRunner.class);
|
||||
private static final BarnLogger LOG = BarnLogger.getLogger(JobRunner.class);
|
||||
private static final String STDOUT_LOG = "stdout.log";
|
||||
private static final String STDERR_LOG = "stderr.log";
|
||||
|
||||
|
||||
@@ -14,12 +14,10 @@ import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.samsonmedia.barn.config.Config;
|
||||
import com.samsonmedia.barn.jobs.Job;
|
||||
import com.samsonmedia.barn.jobs.JobRepository;
|
||||
import com.samsonmedia.barn.logging.BarnLogger;
|
||||
import com.samsonmedia.barn.state.BarnDirectories;
|
||||
import com.samsonmedia.barn.state.JobState;
|
||||
|
||||
@@ -31,7 +29,7 @@ import com.samsonmedia.barn.state.JobState;
|
||||
*/
|
||||
public class JobScheduler {
|
||||
|
||||
private static final Logger LOG = LoggerFactory.getLogger(JobScheduler.class);
|
||||
private static final BarnLogger LOG = BarnLogger.getLogger(JobScheduler.class);
|
||||
private static final Duration DEFAULT_POLL_INTERVAL = Duration.ofSeconds(1);
|
||||
private static final Duration DEFAULT_SHUTDOWN_TIMEOUT = Duration.ofMinutes(5);
|
||||
|
||||
|
||||
@@ -10,8 +10,7 @@ import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import com.samsonmedia.barn.logging.BarnLogger;
|
||||
|
||||
/**
|
||||
* Executes processes and captures their output.
|
||||
@@ -21,7 +20,7 @@ import org.slf4j.LoggerFactory;
|
||||
*/
|
||||
public class ProcessExecutor {
|
||||
|
||||
private static final Logger LOG = LoggerFactory.getLogger(ProcessExecutor.class);
|
||||
private static final BarnLogger LOG = BarnLogger.getLogger(ProcessExecutor.class);
|
||||
|
||||
/**
|
||||
* Executes a command and returns the process.
|
||||
|
||||
@@ -9,8 +9,7 @@ import java.util.concurrent.ScheduledExecutorService;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import com.samsonmedia.barn.logging.BarnLogger;
|
||||
|
||||
/**
|
||||
* Monitors a running process and emits events.
|
||||
@@ -20,7 +19,7 @@ import org.slf4j.LoggerFactory;
|
||||
*/
|
||||
public class ProcessMonitor {
|
||||
|
||||
private static final Logger LOG = LoggerFactory.getLogger(ProcessMonitor.class);
|
||||
private static final BarnLogger LOG = BarnLogger.getLogger(ProcessMonitor.class);
|
||||
private static final Duration DEFAULT_HEARTBEAT_INTERVAL = Duration.ofSeconds(10);
|
||||
|
||||
private final Duration heartbeatInterval;
|
||||
|
||||
@@ -2,8 +2,7 @@ package com.samsonmedia.barn.execution;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import com.samsonmedia.barn.logging.BarnLogger;
|
||||
|
||||
/**
|
||||
* Cross-platform process utilities.
|
||||
@@ -13,7 +12,7 @@ import org.slf4j.LoggerFactory;
|
||||
*/
|
||||
public final class ProcessUtils {
|
||||
|
||||
private static final Logger LOG = LoggerFactory.getLogger(ProcessUtils.class);
|
||||
private static final BarnLogger LOG = BarnLogger.getLogger(ProcessUtils.class);
|
||||
|
||||
private ProcessUtils() {
|
||||
// Utility class - prevent instantiation
|
||||
|
||||
@@ -10,8 +10,7 @@ import java.nio.file.StandardOpenOption;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import com.samsonmedia.barn.logging.BarnLogger;
|
||||
|
||||
/**
|
||||
* Lock to ensure only one scheduler runs at a time.
|
||||
@@ -21,7 +20,7 @@ import org.slf4j.LoggerFactory;
|
||||
*/
|
||||
public final class SchedulerLock implements Closeable {
|
||||
|
||||
private static final Logger LOG = LoggerFactory.getLogger(SchedulerLock.class);
|
||||
private static final BarnLogger LOG = BarnLogger.getLogger(SchedulerLock.class);
|
||||
|
||||
private final Path lockFile;
|
||||
private final FileChannel channel;
|
||||
|
||||
@@ -15,12 +15,10 @@ import java.nio.file.Path;
|
||||
import java.util.Locale;
|
||||
import java.util.Objects;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.SerializationFeature;
|
||||
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
|
||||
import com.samsonmedia.barn.logging.BarnLogger;
|
||||
|
||||
/**
|
||||
* IPC client for communicating with the barn service.
|
||||
@@ -30,7 +28,7 @@ import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
|
||||
*/
|
||||
public class IpcClient implements AutoCloseable {
|
||||
|
||||
private static final Logger LOG = LoggerFactory.getLogger(IpcClient.class);
|
||||
private static final BarnLogger LOG = BarnLogger.getLogger(IpcClient.class);
|
||||
private static final int DEFAULT_TIMEOUT_MS = 30000;
|
||||
|
||||
private final Path socketPath;
|
||||
|
||||
@@ -18,12 +18,10 @@ import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.SerializationFeature;
|
||||
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
|
||||
import com.samsonmedia.barn.logging.BarnLogger;
|
||||
|
||||
/**
|
||||
* IPC server for receiving requests from CLI clients.
|
||||
@@ -32,7 +30,7 @@ import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
|
||||
*/
|
||||
public class IpcServer {
|
||||
|
||||
private static final Logger LOG = LoggerFactory.getLogger(IpcServer.class);
|
||||
private static final BarnLogger LOG = BarnLogger.getLogger(IpcServer.class);
|
||||
|
||||
private final Path socketPath;
|
||||
private final RequestHandler handler;
|
||||
|
||||
@@ -10,13 +10,11 @@ import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.SerializationFeature;
|
||||
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
|
||||
import com.samsonmedia.barn.config.JobsConfig;
|
||||
import com.samsonmedia.barn.logging.BarnLogger;
|
||||
import com.samsonmedia.barn.state.AtomicFiles;
|
||||
import com.samsonmedia.barn.state.BarnDirectories;
|
||||
import com.samsonmedia.barn.state.JobState;
|
||||
@@ -30,7 +28,7 @@ import com.samsonmedia.barn.state.StateFiles;
|
||||
*/
|
||||
public class JobRepository {
|
||||
|
||||
private static final Logger LOG = LoggerFactory.getLogger(JobRepository.class);
|
||||
private static final BarnLogger LOG = BarnLogger.getLogger(JobRepository.class);
|
||||
private static final String MANIFEST_FILE = "manifest.json";
|
||||
|
||||
private final BarnDirectories dirs;
|
||||
|
||||
@@ -0,0 +1,170 @@
|
||||
package com.samsonmedia.barn.logging;
|
||||
|
||||
import java.io.PrintStream;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
|
||||
/**
|
||||
* Simple logger for Barn that can be globally disabled for CLI commands.
|
||||
*
|
||||
* <p>CLI commands should not produce any log output to avoid breaking
|
||||
* JSON/XML output. The service enables logging on startup.
|
||||
*/
|
||||
public final class BarnLogger {
|
||||
|
||||
private static final DateTimeFormatter FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSS");
|
||||
private static volatile boolean enabled = false;
|
||||
private static volatile Level level = Level.INFO;
|
||||
private static volatile PrintStream output = System.err;
|
||||
|
||||
/**
|
||||
* Log levels supported by BarnLogger.
|
||||
*/
|
||||
public enum Level {
|
||||
DEBUG(0), INFO(1), WARN(2), ERROR(3), OFF(4);
|
||||
|
||||
private final int value;
|
||||
|
||||
Level(int value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
boolean isEnabled(Level threshold) {
|
||||
return this.value >= threshold.value;
|
||||
}
|
||||
}
|
||||
|
||||
private final String name;
|
||||
|
||||
private BarnLogger(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public static BarnLogger getLogger(Class<?> clazz) {
|
||||
return new BarnLogger(clazz.getSimpleName());
|
||||
}
|
||||
|
||||
public static BarnLogger getLogger(String name) {
|
||||
return new BarnLogger(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Enables logging globally. Called by the service on startup.
|
||||
*/
|
||||
public static void enable() {
|
||||
enabled = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Disables logging globally. Default state for CLI commands.
|
||||
*/
|
||||
public static void disable() {
|
||||
enabled = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the global log level.
|
||||
*/
|
||||
public static void setLevel(Level newLevel) {
|
||||
level = newLevel;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the current global log level.
|
||||
*
|
||||
* @return the current log level
|
||||
*/
|
||||
public static Level getLevel() {
|
||||
return level;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the output stream for logs.
|
||||
*/
|
||||
public static void setOutput(PrintStream stream) {
|
||||
output = stream;
|
||||
}
|
||||
|
||||
/**
|
||||
* Logs a trace-level message. Mapped to DEBUG level.
|
||||
*/
|
||||
public void trace(String message, Object... args) {
|
||||
log(Level.DEBUG, message, args);
|
||||
}
|
||||
|
||||
public void debug(String message, Object... args) {
|
||||
log(Level.DEBUG, message, args);
|
||||
}
|
||||
|
||||
public void info(String message, Object... args) {
|
||||
log(Level.INFO, message, args);
|
||||
}
|
||||
|
||||
public void warn(String message, Object... args) {
|
||||
log(Level.WARN, message, args);
|
||||
}
|
||||
|
||||
public void error(String message, Object... args) {
|
||||
log(Level.ERROR, message, args);
|
||||
}
|
||||
|
||||
/**
|
||||
* Logs an error message with a throwable.
|
||||
*
|
||||
* @param message the message to log
|
||||
* @param t the throwable to log
|
||||
*/
|
||||
public void error(String message, Throwable t) {
|
||||
if (!enabled || !Level.ERROR.isEnabled(level)) {
|
||||
return;
|
||||
}
|
||||
String timestamp = LocalDateTime.now().format(FORMATTER);
|
||||
output.println(String.format("%s [%s] ERROR %s - %s",
|
||||
timestamp, Thread.currentThread().getName(), name, message));
|
||||
if (t != null) {
|
||||
t.printStackTrace(output);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isDebugEnabled() {
|
||||
return enabled && Level.DEBUG.isEnabled(level);
|
||||
}
|
||||
|
||||
public boolean isInfoEnabled() {
|
||||
return enabled && Level.INFO.isEnabled(level);
|
||||
}
|
||||
|
||||
private void log(Level msgLevel, String message, Object... args) {
|
||||
if (!enabled || !msgLevel.isEnabled(level)) {
|
||||
return;
|
||||
}
|
||||
String timestamp = LocalDateTime.now().format(FORMATTER);
|
||||
String formattedMessage = formatMessage(message, args);
|
||||
output.println(String.format("%s [%s] %-5s %s - %s",
|
||||
timestamp, Thread.currentThread().getName(), msgLevel, name, formattedMessage));
|
||||
}
|
||||
|
||||
private String formatMessage(String message, Object... args) {
|
||||
if (args == null || args.length == 0) {
|
||||
return message;
|
||||
}
|
||||
// Simple {} placeholder replacement like SLF4J
|
||||
StringBuilder sb = new StringBuilder();
|
||||
int argIndex = 0;
|
||||
int i = 0;
|
||||
while (i < message.length()) {
|
||||
if (i < message.length() - 1 && message.charAt(i) == '{' && message.charAt(i + 1) == '}') {
|
||||
if (argIndex < args.length) {
|
||||
sb.append(args[argIndex++]);
|
||||
} else {
|
||||
sb.append("{}");
|
||||
}
|
||||
i += 2;
|
||||
} else {
|
||||
sb.append(message.charAt(i));
|
||||
i++;
|
||||
}
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
@@ -4,9 +4,6 @@ import java.time.Duration;
|
||||
import java.time.Instant;
|
||||
import java.util.Objects;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.samsonmedia.barn.jobs.Job;
|
||||
|
||||
/**
|
||||
@@ -16,7 +13,7 @@ import com.samsonmedia.barn.jobs.Job;
|
||||
*/
|
||||
public final class JobLogEvents {
|
||||
|
||||
private static final Logger LOG = LoggerFactory.getLogger(JobLogEvents.class);
|
||||
private static final BarnLogger LOG = BarnLogger.getLogger(JobLogEvents.class);
|
||||
|
||||
private JobLogEvents() {
|
||||
// Utility class
|
||||
|
||||
@@ -5,14 +5,8 @@ import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.Objects;
|
||||
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.samsonmedia.barn.config.LogLevel;
|
||||
|
||||
import ch.qos.logback.classic.Level;
|
||||
import ch.qos.logback.classic.Logger;
|
||||
import ch.qos.logback.classic.LoggerContext;
|
||||
|
||||
/**
|
||||
* Configuration utilities for the logging system.
|
||||
*
|
||||
@@ -25,17 +19,15 @@ public final class LoggingConfig {
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the root log level at runtime.
|
||||
* Sets the root log level at runtime and enables logging.
|
||||
*
|
||||
* @param level the log level to set
|
||||
* @throws NullPointerException if level is null
|
||||
*/
|
||||
public static void setLogLevel(LogLevel level) {
|
||||
Objects.requireNonNull(level, "level must not be null");
|
||||
|
||||
LoggerContext context = (LoggerContext) LoggerFactory.getILoggerFactory();
|
||||
Logger rootLogger = context.getLogger(Logger.ROOT_LOGGER_NAME);
|
||||
rootLogger.setLevel(toLogbackLevel(level));
|
||||
BarnLogger.enable();
|
||||
BarnLogger.setLevel(toBarnLoggerLevel(level));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -44,9 +36,7 @@ public final class LoggingConfig {
|
||||
* @return the current log level
|
||||
*/
|
||||
public static LogLevel getLogLevel() {
|
||||
LoggerContext context = (LoggerContext) LoggerFactory.getILoggerFactory();
|
||||
Logger rootLogger = context.getLogger(Logger.ROOT_LOGGER_NAME);
|
||||
return fromLogbackLevel(rootLogger.getLevel());
|
||||
return fromBarnLoggerLevel(BarnLogger.getLevel());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -79,28 +69,21 @@ public final class LoggingConfig {
|
||||
return Path.of(System.getProperty("java.io.tmpdir"), "barn", "logs");
|
||||
}
|
||||
|
||||
private static Level toLogbackLevel(LogLevel level) {
|
||||
private static BarnLogger.Level toBarnLoggerLevel(LogLevel level) {
|
||||
return switch (level) {
|
||||
case DEBUG -> Level.DEBUG;
|
||||
case INFO -> Level.INFO;
|
||||
case WARN -> Level.WARN;
|
||||
case ERROR -> Level.ERROR;
|
||||
case DEBUG -> BarnLogger.Level.DEBUG;
|
||||
case INFO -> BarnLogger.Level.INFO;
|
||||
case WARN -> BarnLogger.Level.WARN;
|
||||
case ERROR -> BarnLogger.Level.ERROR;
|
||||
};
|
||||
}
|
||||
|
||||
private static LogLevel fromLogbackLevel(Level level) {
|
||||
if (level == null || level.equals(Level.INFO)) {
|
||||
return LogLevel.INFO;
|
||||
}
|
||||
if (level.equals(Level.DEBUG) || level.equals(Level.TRACE)) {
|
||||
return LogLevel.DEBUG;
|
||||
}
|
||||
if (level.equals(Level.WARN)) {
|
||||
return LogLevel.WARN;
|
||||
}
|
||||
if (level.equals(Level.ERROR) || level.equals(Level.OFF)) {
|
||||
return LogLevel.ERROR;
|
||||
}
|
||||
return LogLevel.INFO;
|
||||
private static LogLevel fromBarnLoggerLevel(BarnLogger.Level level) {
|
||||
return switch (level) {
|
||||
case DEBUG -> LogLevel.DEBUG;
|
||||
case INFO -> LogLevel.INFO;
|
||||
case WARN -> LogLevel.WARN;
|
||||
case ERROR, OFF -> LogLevel.ERROR;
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -12,8 +12,7 @@ import java.util.Optional;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import com.samsonmedia.barn.logging.BarnLogger;
|
||||
|
||||
/**
|
||||
* Collects resource usage metrics for a process.
|
||||
@@ -22,7 +21,7 @@ import org.slf4j.LoggerFactory;
|
||||
*/
|
||||
public class UsageCollector {
|
||||
|
||||
private static final Logger LOG = LoggerFactory.getLogger(UsageCollector.class);
|
||||
private static final BarnLogger LOG = BarnLogger.getLogger(UsageCollector.class);
|
||||
private static final int COMMAND_TIMEOUT_SECONDS = 5;
|
||||
|
||||
private final boolean isWindows;
|
||||
|
||||
@@ -8,8 +8,7 @@ import java.nio.file.Path;
|
||||
import java.nio.file.StandardOpenOption;
|
||||
import java.util.Objects;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import com.samsonmedia.barn.logging.BarnLogger;
|
||||
|
||||
/**
|
||||
* Writes usage records to a CSV file.
|
||||
@@ -18,7 +17,7 @@ import org.slf4j.LoggerFactory;
|
||||
*/
|
||||
public class UsageLogger implements Closeable {
|
||||
|
||||
private static final Logger LOG = LoggerFactory.getLogger(UsageLogger.class);
|
||||
private static final BarnLogger LOG = BarnLogger.getLogger(UsageLogger.class);
|
||||
|
||||
/** Default filename for usage logs. */
|
||||
public static final String USAGE_LOG_FILENAME = "usage.csv";
|
||||
|
||||
@@ -10,8 +10,7 @@ import java.util.concurrent.ScheduledFuture;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import com.samsonmedia.barn.logging.BarnLogger;
|
||||
|
||||
/**
|
||||
* Monitors resource usage for a process over time.
|
||||
@@ -20,7 +19,7 @@ import org.slf4j.LoggerFactory;
|
||||
*/
|
||||
public class UsageMonitor implements Closeable {
|
||||
|
||||
private static final Logger LOG = LoggerFactory.getLogger(UsageMonitor.class);
|
||||
private static final BarnLogger LOG = BarnLogger.getLogger(UsageMonitor.class);
|
||||
|
||||
/** Default collection interval in seconds. */
|
||||
public static final int DEFAULT_INTERVAL_SECONDS = 5;
|
||||
|
||||
@@ -11,8 +11,7 @@ import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import com.samsonmedia.barn.logging.BarnLogger;
|
||||
|
||||
/**
|
||||
* Manages Linux systemd service operations.
|
||||
@@ -22,7 +21,7 @@ import org.slf4j.LoggerFactory;
|
||||
*/
|
||||
public class SystemdManager {
|
||||
|
||||
private static final Logger LOG = LoggerFactory.getLogger(SystemdManager.class);
|
||||
private static final BarnLogger LOG = BarnLogger.getLogger(SystemdManager.class);
|
||||
private static final String SERVICE_NAME = "barn.service";
|
||||
private static final long COMMAND_TIMEOUT_SECONDS = 30;
|
||||
|
||||
|
||||
@@ -9,8 +9,7 @@ import java.nio.file.Path;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import com.samsonmedia.barn.logging.BarnLogger;
|
||||
|
||||
/**
|
||||
* Manages macOS launchd service operations.
|
||||
@@ -20,7 +19,7 @@ import org.slf4j.LoggerFactory;
|
||||
*/
|
||||
public class LaunchdManager {
|
||||
|
||||
private static final Logger LOG = LoggerFactory.getLogger(LaunchdManager.class);
|
||||
private static final BarnLogger LOG = BarnLogger.getLogger(LaunchdManager.class);
|
||||
private static final String LABEL = "com.samsonmedia.barn";
|
||||
private static final long COMMAND_TIMEOUT_SECONDS = 30;
|
||||
|
||||
|
||||
@@ -10,8 +10,7 @@ import java.util.Locale;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import com.samsonmedia.barn.logging.BarnLogger;
|
||||
|
||||
/**
|
||||
* Manages Windows service operations using sc.exe.
|
||||
@@ -21,7 +20,7 @@ import org.slf4j.LoggerFactory;
|
||||
*/
|
||||
public class WindowsServiceManager {
|
||||
|
||||
private static final Logger LOG = LoggerFactory.getLogger(WindowsServiceManager.class);
|
||||
private static final BarnLogger LOG = BarnLogger.getLogger(WindowsServiceManager.class);
|
||||
private static final String SERVICE_NAME = "barn";
|
||||
private static final String DISPLAY_NAME = "Barn Job Daemon";
|
||||
private static final long COMMAND_TIMEOUT_SECONDS = 30;
|
||||
|
||||
@@ -9,9 +9,6 @@ import java.util.Objects;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
|
||||
import com.samsonmedia.barn.config.Config;
|
||||
@@ -24,6 +21,7 @@ import com.samsonmedia.barn.ipc.IpcException;
|
||||
import com.samsonmedia.barn.ipc.IpcServer;
|
||||
import com.samsonmedia.barn.jobs.Job;
|
||||
import com.samsonmedia.barn.jobs.JobRepository;
|
||||
import com.samsonmedia.barn.logging.BarnLogger;
|
||||
import com.samsonmedia.barn.logging.LoggingConfig;
|
||||
import com.samsonmedia.barn.state.BarnDirectories;
|
||||
import com.samsonmedia.barn.state.JobState;
|
||||
@@ -41,7 +39,7 @@ import com.samsonmedia.barn.state.JobState;
|
||||
*/
|
||||
public class BarnService {
|
||||
|
||||
private static final Logger LOG = LoggerFactory.getLogger(BarnService.class);
|
||||
private static final BarnLogger LOG = BarnLogger.getLogger(BarnService.class);
|
||||
|
||||
private final Config config;
|
||||
private final BarnDirectories dirs;
|
||||
|
||||
@@ -10,12 +10,10 @@ import java.util.concurrent.ScheduledExecutorService;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.samsonmedia.barn.config.CleanupConfig;
|
||||
import com.samsonmedia.barn.jobs.Job;
|
||||
import com.samsonmedia.barn.jobs.JobRepository;
|
||||
import com.samsonmedia.barn.logging.BarnLogger;
|
||||
import com.samsonmedia.barn.state.JobState;
|
||||
|
||||
/**
|
||||
@@ -23,7 +21,7 @@ import com.samsonmedia.barn.state.JobState;
|
||||
*/
|
||||
public class CleanupScheduler {
|
||||
|
||||
private static final Logger LOG = LoggerFactory.getLogger(CleanupScheduler.class);
|
||||
private static final BarnLogger LOG = BarnLogger.getLogger(CleanupScheduler.class);
|
||||
|
||||
private final JobRepository repository;
|
||||
private final CleanupConfig config;
|
||||
|
||||
@@ -9,8 +9,7 @@ import java.nio.file.StandardOpenOption;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import com.samsonmedia.barn.logging.BarnLogger;
|
||||
|
||||
/**
|
||||
* A file-based lock for coordinating access to resources.
|
||||
@@ -20,7 +19,7 @@ import org.slf4j.LoggerFactory;
|
||||
*/
|
||||
public final class FileLock implements AutoCloseable {
|
||||
|
||||
private static final Logger LOG = LoggerFactory.getLogger(FileLock.class);
|
||||
private static final BarnLogger LOG = BarnLogger.getLogger(FileLock.class);
|
||||
|
||||
private final Path lockFile;
|
||||
private final FileChannel channel;
|
||||
|
||||
+42
-168
@@ -1,187 +1,61 @@
|
||||
[
|
||||
{
|
||||
"name": "com.samsonmedia.barn.ipc.IpcMessage",
|
||||
"allDeclaredConstructors": true,
|
||||
"allPublicConstructors": true,
|
||||
"allDeclaredMethods": true,
|
||||
"allPublicMethods": true,
|
||||
"allDeclaredFields": true
|
||||
},
|
||||
{
|
||||
"name": "com.samsonmedia.barn.ipc.IpcRequest$RunJob",
|
||||
"allDeclaredConstructors": true,
|
||||
"allPublicConstructors": true,
|
||||
"allDeclaredMethods": true,
|
||||
"allPublicMethods": true,
|
||||
"allDeclaredFields": true
|
||||
},
|
||||
{
|
||||
"name": "com.samsonmedia.barn.ipc.IpcRequest$GetStatus",
|
||||
"allDeclaredConstructors": true,
|
||||
"allPublicConstructors": true,
|
||||
"allDeclaredMethods": true,
|
||||
"allPublicMethods": true,
|
||||
"allDeclaredFields": true
|
||||
},
|
||||
{
|
||||
"name": "com.samsonmedia.barn.ipc.IpcRequest$GetJob",
|
||||
"allDeclaredConstructors": true,
|
||||
"allPublicConstructors": true,
|
||||
"allDeclaredMethods": true,
|
||||
"allPublicMethods": true,
|
||||
"allDeclaredFields": true
|
||||
},
|
||||
{
|
||||
"name": "com.samsonmedia.barn.ipc.IpcRequest$KillJob",
|
||||
"allDeclaredConstructors": true,
|
||||
"allPublicConstructors": true,
|
||||
"allDeclaredMethods": true,
|
||||
"allPublicMethods": true,
|
||||
"allDeclaredFields": true
|
||||
},
|
||||
{
|
||||
"name": "com.samsonmedia.barn.ipc.IpcRequest$CleanJobs",
|
||||
"allDeclaredConstructors": true,
|
||||
"allPublicConstructors": true,
|
||||
"allDeclaredMethods": true,
|
||||
"allPublicMethods": true,
|
||||
"allDeclaredFields": true
|
||||
},
|
||||
{
|
||||
"name": "com.samsonmedia.barn.ipc.IpcRequest$GetServiceStatus",
|
||||
"allDeclaredConstructors": true,
|
||||
"allPublicConstructors": true,
|
||||
"allDeclaredMethods": true,
|
||||
"allPublicMethods": true,
|
||||
"allDeclaredFields": true
|
||||
},
|
||||
{
|
||||
"name": "com.samsonmedia.barn.ipc.IpcRequest$Shutdown",
|
||||
"allDeclaredConstructors": true,
|
||||
"allPublicConstructors": true,
|
||||
"allDeclaredMethods": true,
|
||||
"allPublicMethods": true,
|
||||
"allDeclaredFields": true
|
||||
},
|
||||
{
|
||||
"name": "com.samsonmedia.barn.ipc.IpcRequest$Reload",
|
||||
"allDeclaredConstructors": true,
|
||||
"allPublicConstructors": true,
|
||||
"allDeclaredMethods": true,
|
||||
"allPublicMethods": true,
|
||||
"allDeclaredFields": true
|
||||
},
|
||||
{
|
||||
"name": "com.samsonmedia.barn.ipc.IpcResponse$Ok",
|
||||
"allDeclaredConstructors": true,
|
||||
"allPublicConstructors": true,
|
||||
"allDeclaredMethods": true,
|
||||
"allPublicMethods": true,
|
||||
"allDeclaredFields": true
|
||||
},
|
||||
{
|
||||
"name": "com.samsonmedia.barn.ipc.IpcResponse$Error",
|
||||
"allDeclaredConstructors": true,
|
||||
"allPublicConstructors": true,
|
||||
"allDeclaredMethods": true,
|
||||
"allPublicMethods": true,
|
||||
"allDeclaredFields": true
|
||||
},
|
||||
{
|
||||
"name": "com.samsonmedia.barn.jobs.Job",
|
||||
"allDeclaredConstructors": true,
|
||||
"allPublicConstructors": true,
|
||||
"allDeclaredMethods": true,
|
||||
"allPublicMethods": true,
|
||||
"allDeclaredFields": true
|
||||
},
|
||||
{
|
||||
"name": "com.samsonmedia.barn.jobs.JobManifest",
|
||||
"allDeclaredConstructors": true,
|
||||
"allPublicConstructors": true,
|
||||
"allDeclaredMethods": true,
|
||||
"allPublicMethods": true,
|
||||
"allDeclaredFields": true
|
||||
},
|
||||
{
|
||||
"name": "com.samsonmedia.barn.state.JobState",
|
||||
"allDeclaredConstructors": true,
|
||||
"allPublicConstructors": true,
|
||||
"allDeclaredMethods": true,
|
||||
"allPublicMethods": true,
|
||||
"allDeclaredFields": true
|
||||
},
|
||||
{
|
||||
"name": "com.samsonmedia.barn.execution.ResourceUsage",
|
||||
"allDeclaredConstructors": true,
|
||||
"allPublicConstructors": true,
|
||||
"allDeclaredMethods": true,
|
||||
"allPublicMethods": true,
|
||||
"allDeclaredFields": true
|
||||
},
|
||||
{
|
||||
"name": "com.samsonmedia.barn.config.Config",
|
||||
"allDeclaredConstructors": true,
|
||||
"allPublicConstructors": true,
|
||||
"allDeclaredMethods": true,
|
||||
"allPublicMethods": true,
|
||||
"allDeclaredFields": true
|
||||
},
|
||||
{
|
||||
"name": "com.samsonmedia.barn.config.ServiceConfig",
|
||||
"allDeclaredConstructors": true,
|
||||
"allPublicConstructors": true,
|
||||
"allDeclaredMethods": true,
|
||||
"allPublicMethods": true,
|
||||
"allDeclaredFields": true
|
||||
},
|
||||
{
|
||||
"name": "com.samsonmedia.barn.config.StorageConfig",
|
||||
"allDeclaredConstructors": true,
|
||||
"allPublicConstructors": true,
|
||||
"allDeclaredMethods": true,
|
||||
"allPublicMethods": true,
|
||||
"allDeclaredFields": true
|
||||
},
|
||||
{
|
||||
"name": "com.samsonmedia.barn.config.JobsConfig",
|
||||
"allDeclaredConstructors": true,
|
||||
"allPublicConstructors": true,
|
||||
"allDeclaredMethods": true,
|
||||
"allPublicMethods": true,
|
||||
"allDeclaredFields": true
|
||||
},
|
||||
{
|
||||
"name": "com.samsonmedia.barn.config.CleanupConfig",
|
||||
"allDeclaredConstructors": true,
|
||||
"allPublicConstructors": true,
|
||||
"allDeclaredMethods": true,
|
||||
"allPublicMethods": true,
|
||||
"allDeclaredFields": true
|
||||
},
|
||||
{
|
||||
"name": "java.util.LinkedHashMap",
|
||||
"name": "ch.qos.logback.core.status.NopStatusListener",
|
||||
"allDeclaredConstructors": true,
|
||||
"allPublicConstructors": true
|
||||
},
|
||||
{
|
||||
"name": "java.util.HashMap",
|
||||
"name": "ch.qos.logback.core.helpers.NOPAppender",
|
||||
"allDeclaredConstructors": true,
|
||||
"allPublicConstructors": true
|
||||
},
|
||||
{
|
||||
"name": "java.util.ArrayList",
|
||||
"name": "ch.qos.logback.core.FileAppender",
|
||||
"allDeclaredConstructors": true,
|
||||
"allPublicConstructors": true
|
||||
"allPublicConstructors": true,
|
||||
"allDeclaredMethods": true,
|
||||
"allPublicMethods": true
|
||||
},
|
||||
{
|
||||
"name": "java.util.ImmutableCollections$ListN",
|
||||
"name": "ch.qos.logback.core.rolling.RollingFileAppender",
|
||||
"allDeclaredConstructors": true,
|
||||
"allPublicConstructors": true
|
||||
"allPublicConstructors": true,
|
||||
"allDeclaredMethods": true,
|
||||
"allPublicMethods": true
|
||||
},
|
||||
{
|
||||
"name": "java.util.ImmutableCollections$List12",
|
||||
"name": "ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy",
|
||||
"allDeclaredConstructors": true,
|
||||
"allPublicConstructors": true
|
||||
"allPublicConstructors": true,
|
||||
"allDeclaredMethods": true,
|
||||
"allPublicMethods": true
|
||||
},
|
||||
{
|
||||
"name": "ch.qos.logback.classic.encoder.PatternLayoutEncoder",
|
||||
"allDeclaredConstructors": true,
|
||||
"allPublicConstructors": true,
|
||||
"allDeclaredMethods": true,
|
||||
"allPublicMethods": true
|
||||
},
|
||||
{
|
||||
"name": "ch.qos.logback.core.ConsoleAppender",
|
||||
"allDeclaredConstructors": true,
|
||||
"allPublicConstructors": true,
|
||||
"allDeclaredMethods": true,
|
||||
"allPublicMethods": true
|
||||
},
|
||||
{
|
||||
"name": "ch.qos.logback.classic.PatternLayout",
|
||||
"allDeclaredConstructors": true,
|
||||
"allPublicConstructors": true,
|
||||
"allDeclaredMethods": true,
|
||||
"allPublicMethods": true
|
||||
},
|
||||
{
|
||||
"name": "net.logstash.logback.encoder.LogstashEncoder",
|
||||
"allDeclaredConstructors": true,
|
||||
"allPublicConstructors": true,
|
||||
"allDeclaredMethods": true,
|
||||
"allPublicMethods": true
|
||||
}
|
||||
]
|
||||
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"resources": {
|
||||
"includes": [
|
||||
{"pattern": "logback.xml"},
|
||||
{"pattern": "META-INF/.*"}
|
||||
]
|
||||
},
|
||||
"bundles": []
|
||||
}
|
||||
@@ -1,40 +1,24 @@
|
||||
<configuration>
|
||||
<!-- Suppress logback's internal status messages -->
|
||||
<configuration debug="false">
|
||||
<!-- Suppress ALL logback output including internal status -->
|
||||
<statusListener class="ch.qos.logback.core.status.NopStatusListener" />
|
||||
|
||||
<!-- File appender for service logging -->
|
||||
<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||
<file>${BARN_LOG_DIR:-${java.io.tmpdir}/barn/logs}/barn.log</file>
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
|
||||
<fileNamePattern>${BARN_LOG_DIR:-${java.io.tmpdir}/barn/logs}/barn.%d{yyyy-MM-dd}.%i.log.gz</fileNamePattern>
|
||||
<maxFileSize>10MB</maxFileSize>
|
||||
<maxHistory>7</maxHistory>
|
||||
<totalSizeCap>100MB</totalSizeCap>
|
||||
</rollingPolicy>
|
||||
<!-- NOP appender - discards all logs -->
|
||||
<appender name="NOP" class="ch.qos.logback.core.helpers.NOPAppender"/>
|
||||
|
||||
<!-- File appender for service logging (only used when service enables it) -->
|
||||
<appender name="FILE" class="ch.qos.logback.core.FileAppender">
|
||||
<file>/tmp/barn/logs/barn.log</file>
|
||||
<append>true</append>
|
||||
<encoder>
|
||||
<pattern>%d{ISO8601} [%thread] %-5level %logger{36} - %msg%n</pattern>
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
<!-- JSON appender for structured logging -->
|
||||
<appender name="JSON" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||
<file>${BARN_LOG_DIR:-${java.io.tmpdir}/barn/logs}/barn.json.log</file>
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
|
||||
<fileNamePattern>${BARN_LOG_DIR:-${java.io.tmpdir}/barn/logs}/barn.json.%d{yyyy-MM-dd}.%i.log.gz</fileNamePattern>
|
||||
<maxFileSize>10MB</maxFileSize>
|
||||
<maxHistory>7</maxHistory>
|
||||
</rollingPolicy>
|
||||
<encoder class="net.logstash.logback.encoder.LogstashEncoder">
|
||||
<includeMdcKeyName>jobId</includeMdcKeyName>
|
||||
<includeMdcKeyName>jobTag</includeMdcKeyName>
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
<!--
|
||||
Root logger OFF by default - CLI commands produce no log output.
|
||||
Service startup explicitly enables logging via LoggingConfig.
|
||||
-->
|
||||
<root level="OFF">
|
||||
<appender-ref ref="FILE"/>
|
||||
<appender-ref ref="NOP"/>
|
||||
</root>
|
||||
</configuration>
|
||||
Reference in new issue
Block a user