logging

package
v1.83.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 14, 2026 License: MPL-2.0 Imports: 6 Imported by: 0

Documentation

Overview

============================================================================= NFTBan v1.73 - Installer Dual Logger ============================================================================= SPDX-License-Identifier: MPL-2.0 meta:name="installer-logger" meta:type="lib" meta:owner="Antonios Voulvoulis <contact@nftban.com>" meta:created_date="2026-04-04" meta:description="Dual console+file logger for installer output" meta:inventory.files="internal/installer/logging/logger.go" meta:inventory.binaries="" meta:inventory.env_vars="" meta:inventory.config_files="/var/log/nftban/installer.log" meta:inventory.systemd_units="" meta:inventory.network="" meta:inventory.privileges="root" =============================================================================

Index

Constants

View Source
const DefaultLogPath = "/var/log/nftban/installer.log"

DefaultLogPath is the standard installer log location.

Variables

This section is empty.

Functions

This section is empty.

Types

type Logger

type Logger struct {
	// contains filtered or unexported fields
}

Logger writes to both console and a persistent log file. The log file is append-only — every install/update/repair run is preserved as a contiguous block delimited by RunHeader/RunFooter for post-mortem analysis.

func New

func New(logPath string, verbose bool) *Logger

New creates a Logger. logPath may be empty to use DefaultLogPath. If the log file cannot be opened, logging continues to console only.

func (*Logger) Close

func (l *Logger) Close()

Close flushes and closes the log file.

func (*Logger) CmdResult

func (l *Logger) CmdResult(name string, exitCode int, stderr string)

CmdResult logs the result of a command execution. This captures every external command's exit code and stderr for root cause analysis. Only writes to file (not console) unless verbose or non-zero exit.

func (*Logger) Debug

func (l *Logger) Debug(format string, args ...interface{})

Debug logs a debug message to file always, and to console only if verbose.

func (*Logger) Detect

func (l *Logger) Detect(category, key, value string)

Detect logs a detection result (SSH, panel, conflicts, authority). These are the key facts needed for root cause analysis.

func (*Logger) Error

func (l *Logger) Error(format string, args ...interface{})

Error logs an error to both console and file.

func (*Logger) Info

func (l *Logger) Info(format string, args ...interface{})

Info logs an informational message to both console and file.

func (*Logger) LogPath

func (l *Logger) LogPath() string

LogPath returns the path to the log file being written.

func (*Logger) Phase

func (l *Logger) Phase(name string)

Phase prints a phase separator banner and records the phase start time.

func (*Logger) PhaseEnd

func (l *Logger) PhaseEnd(name string)

PhaseEnd records the elapsed time for the current phase. Called automatically by Phase() for the previous phase, but should also be called for the final phase.

func (*Logger) Result

func (l *Logger) Result(format string, args ...interface{})

Result prints a final result line (no timestamp on console for cleaner output).

func (*Logger) RunFooter

func (l *Logger) RunFooter(finalState string, exitCode int)

RunFooter writes the closing delimiter with elapsed time and final state.

func (*Logger) RunHeader

func (l *Logger) RunHeader(version, mode, hostname, osInfo string)

RunHeader writes a clear delimiter block marking the start of an installer run. This is essential for finding where a specific install/update begins in the log.

func (*Logger) StateChange

func (l *Logger) StateChange(from, to, reason string)

StateChange logs a state machine transition to file.

func (*Logger) Warn

func (l *Logger) Warn(format string, args ...interface{})

Warn logs a warning to both console and file.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL