Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

create a new file when file specified by --log-file option doesn't exist #12496

Closed
niekaixuan opened this issue Jun 6, 2023 · 4 comments
Closed
Assignees
Labels
Enhancement New feature or request Good First Issue Good for newcomers Help Wanted Extra attention is needed

Comments

@niekaixuan
Copy link

niekaixuan commented Jun 6, 2023

🚀 Feature Request

Description

prysm start command

./prysm.sh beacon-chain --config-file=/data/ethereum/node/cl/config.yaml

Inside the config.yaml, I specified --log-file to /data/ethereum/node/cl/log/prysm.log and it is not exist before, as a result , there is no log file in my directory, track the journal of the process, I got these prompts

Jun 06 11:26:19  prysm.sh[28341]: time="2023-06-06 11:26:19" level=info msg="Logs will be made persistent" logFileName="/data/ethereum/node/cl/log/prysm.log"
Jun 06 11:26:19  prysm.sh[28341]: time="2023-06-06 11:26:19" level=error msg="Failed to configuring logging to disk." error="open /data/ethereum/node/cl/log/prysm.log: no such file or directory" prefix=main

Describe the solution you'd like

just create a new file when it doesn't exist

Describe alternatives you've considered

@nisdas nisdas added Good First Issue Good for newcomers Enhancement New feature or request Help Wanted Extra attention is needed labels Jul 25, 2023
@bharath-123
Copy link
Contributor

hey @nisdas i ll pick this up

@nisdas
Copy link
Member

nisdas commented Jul 30, 2023

Assigned to you !

@bharath-123
Copy link
Contributor

Hey @nisdas in the latest develop branch, the log-file is being created if it doesn't exist. I have tested this out in the latest develop branch code, plus:

// ConfigurePersistentLogging adds a log-to-file writer. File content is identical to stdout.
func ConfigurePersistentLogging(logFileName string) error {
	logrus.WithField("logFileName", logFileName).Info("Logs will be made persistent")
	f, err := os.OpenFile(logFileName, os.O_CREATE|os.O_WRONLY|os.O_APPEND, params.BeaconIoConfig().ReadWritePermissions) // #nosec G304
	if err != nil {
		return err
	}

	addLogWriter(f)

	logrus.Info("File logging initialized")
	return nil
}

The file modes are set such that the log file is created if not present.

@bharath-123
Copy link
Contributor

apologies, this happens when the directory is not present. will fix for that case

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement New feature or request Good First Issue Good for newcomers Help Wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants