logfiles

package
v0.0.0-...-a4a517a Latest Latest
Warning

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

Go to latest
Published: Aug 23, 2023 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SanDir = "SAN"
	RawDir = "RAW"
	EnvDir = "ENV"

	TodayLink     = "TODAY"
	ThisMonthLink = "THISMONTH"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Command

type Command struct {
	// Trim()'ed version of the command line.
	CommandLine string

	// Command names in a command line. e.g. ["cat", "grep"]
	ExeNames []string

	// Comment in a command line.
	Comment string

	// Whether the command line contained a no log command or had 184.
	// When 186 is detected, the output will always be logged.
	NoLog bool
}

Command represents a single running command executed by the user on the shell.

func ParseCommandLine

func ParseCommandLine(config *config.Config, commandLine string) *Command

ParseCommandLine takes a command line, and extracts a list of the commands and the comment out of it. e.g. "/bin/cat /etc/passwd | grep xxx # find xxx" -> ["cat", "grep"] "find xxx"

type LogFiles

type LogFiles struct {
	SanFile string
	RawFile string
	EnvFile string

	SanF *os.File
	RawF *os.File
	EnvF *os.File

	San *bufio.Writer
	Raw *bufio.Writer
	Env *bufio.Writer
}

LogFiles represents a set of log files (san, raw and env) for a single command.

func CreateAndOpenLogFiles

func CreateAndOpenLogFiles(config *config.Config, now time.Time, command *Command) LogFiles

CreateAndOpenLogFiles opens the log files for a command.

func (*LogFiles) Close

func (l *LogFiles) Close()

Close opens all the log files.

func (*LogFiles) Open

func (l *LogFiles) Open(truncate bool)

Open actually opens the set of the log files.

func (*LogFiles) WriteEnv

func (l *LogFiles) WriteEnv(command *Command, envs string, startTime time.Time)

WriteEnv writes the command start information to the ENV file, and a string given via 'env', to the ENV log file.

func (*LogFiles) WriteFinishToEnv

func (l *LogFiles) WriteFinishToEnv(exitCode int, startTime, finishTime time.Time)

WriteFinishToEnv write the command finish information to the ENV file.

Jump to

Keyboard shortcuts

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