mirror of
				https://codeberg.org/cunicu/cunicu.git
				synced 2025-11-01 01:12:37 +08:00 
			
		
		
		
	add --log-file command line argument
Signed-off-by: Steffen Vogel <post@steffenvogel.de>
This commit is contained in:
		| @@ -17,7 +17,7 @@ var ( | |||||||
| 	docsCmd = &cobra.Command{ | 	docsCmd = &cobra.Command{ | ||||||
| 		Use:    "docs", | 		Use:    "docs", | ||||||
| 		Short:  "Generate documentation for the wice commands", | 		Short:  "Generate documentation for the wice commands", | ||||||
| 		// Hidden: true, | 		Hidden: true, | ||||||
| 		Args:   cobra.NoArgs, | 		Args:   cobra.NoArgs, | ||||||
| 		RunE: func(cmd *cobra.Command, args []string) error { | 		RunE: func(cmd *cobra.Command, args []string) error { | ||||||
| 			if err := docsMarkdown(cmd, args); err != nil { | 			if err := docsMarkdown(cmd, args); err != nil { | ||||||
|   | |||||||
| @@ -47,36 +47,39 @@ var ( | |||||||
|  |  | ||||||
| 		// The main wice command is just an alias for "wice daemon" | 		// The main wice command is just an alias for "wice daemon" | ||||||
| 		Run:               daemon, | 		Run:               daemon, | ||||||
|  | 		DisableAutoGenTag: true, | ||||||
|  | 		Version:           version, | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	version string //lint:ignore U1000 set via ldflags -X / goreleaser | 	version string //lint:ignore U1000 set via ldflags -X / goreleaser | ||||||
| 	commit  string //lint:ignore U1000 set via ldflags -X / goreleaser | 	commit  string //lint:ignore U1000 set via ldflags -X / goreleaser | ||||||
| 	date    string //lint:ignore U1000 set via ldflags -X / goreleaser | 	date    string //lint:ignore U1000 set via ldflags -X / goreleaser | ||||||
|  |  | ||||||
| 	level = logLevel{zapcore.InfoLevel} | 	logLevel = level{zapcore.InfoLevel} | ||||||
|  | 	logFile  string | ||||||
| ) | ) | ||||||
|  |  | ||||||
| type logLevel struct { | type level struct { | ||||||
| 	zapcore.Level | 	zapcore.Level | ||||||
| } | } | ||||||
|  |  | ||||||
| func (l *logLevel) Type() string { | func (l *level) Type() string { | ||||||
| 	return "string" | 	return "string" | ||||||
| } | } | ||||||
|  |  | ||||||
| func init() { | func init() { | ||||||
|  | 	rootCmd.SetUsageTemplate(usageTemplate) | ||||||
|  |  | ||||||
| 	cobra.OnInitialize( | 	cobra.OnInitialize( | ||||||
| 		internal.SetupRand, | 		internal.SetupRand, | ||||||
| 		setupLogging, | 		setupLogging, | ||||||
| 	) | 	) | ||||||
|  |  | ||||||
| 	rootCmd.Version = version |  | ||||||
| 	rootCmd.SetUsageTemplate(usageTemplate) |  | ||||||
|  |  | ||||||
| 	pf := rootCmd.PersistentFlags() | 	pf := rootCmd.PersistentFlags() | ||||||
| 	pf.VarP(&level, "log-level", "d", "log level (one of \"debug\", \"info\", \"warn\", \"error\", \"dpanic\", \"panic\", and \"fatal\")") | 	pf.VarP(&logLevel, "log-level", "d", "log level (one of \"debug\", \"info\", \"warn\", \"error\", \"dpanic\", \"panic\", and \"fatal\")") | ||||||
|  | 	pf.StringVarP(&logFile, "log-file", "l", "", "path of a file to write logs to") | ||||||
| } | } | ||||||
|  |  | ||||||
| func setupLogging() { | func setupLogging() { | ||||||
| 	logger = internal.SetupLogging(level.Level) | 	logger = internal.SetupLogging(logLevel.Level, logFile) | ||||||
| } | } | ||||||
|   | |||||||
| @@ -23,7 +23,7 @@ var ( | |||||||
|  |  | ||||||
| func init() { | func init() { | ||||||
| 	pf := signalCmd.PersistentFlags() | 	pf := signalCmd.PersistentFlags() | ||||||
| 	pf.StringVarP(&listenAddress, "listen", "l", ":443", "listen address") | 	pf.StringVarP(&listenAddress, "listen", "L", ":443", "listen address") | ||||||
|  |  | ||||||
| 	rootCmd.AddCommand(signalCmd) | 	rootCmd.AddCommand(signalCmd) | ||||||
| } | } | ||||||
|   | |||||||
| @@ -69,6 +69,10 @@ You will need to start a new shell for this setup to take effect. | |||||||
|  |  | ||||||
|  |  | ||||||
| .SH OPTIONS INHERITED FROM PARENT COMMANDS | .SH OPTIONS INHERITED FROM PARENT COMMANDS | ||||||
|  | .PP | ||||||
|  | \fB-l\fP, \fB--log-file\fP="" | ||||||
|  | 	path of a file to write logs to | ||||||
|  |  | ||||||
| .PP | .PP | ||||||
| \fB-d\fP, \fB--log-level\fP="info" | \fB-d\fP, \fB--log-level\fP="info" | ||||||
| 	log level (one of "debug", "info", "warn", "error", "dpanic", "panic", and "fatal") | 	log level (one of "debug", "info", "warn", "error", "dpanic", "panic", and "fatal") | ||||||
|   | |||||||
| @@ -54,6 +54,10 @@ You will need to start a new shell for this setup to take effect. | |||||||
|  |  | ||||||
|  |  | ||||||
| .SH OPTIONS INHERITED FROM PARENT COMMANDS | .SH OPTIONS INHERITED FROM PARENT COMMANDS | ||||||
|  | .PP | ||||||
|  | \fB-l\fP, \fB--log-file\fP="" | ||||||
|  | 	path of a file to write logs to | ||||||
|  |  | ||||||
| .PP | .PP | ||||||
| \fB-d\fP, \fB--log-level\fP="info" | \fB-d\fP, \fB--log-level\fP="info" | ||||||
| 	log level (one of "debug", "info", "warn", "error", "dpanic", "panic", and "fatal") | 	log level (one of "debug", "info", "warn", "error", "dpanic", "panic", and "fatal") | ||||||
|   | |||||||
| @@ -43,6 +43,10 @@ to your powershell profile. | |||||||
|  |  | ||||||
|  |  | ||||||
| .SH OPTIONS INHERITED FROM PARENT COMMANDS | .SH OPTIONS INHERITED FROM PARENT COMMANDS | ||||||
|  | .PP | ||||||
|  | \fB-l\fP, \fB--log-file\fP="" | ||||||
|  | 	path of a file to write logs to | ||||||
|  |  | ||||||
| .PP | .PP | ||||||
| \fB-d\fP, \fB--log-level\fP="info" | \fB-d\fP, \fB--log-level\fP="info" | ||||||
| 	log level (one of "debug", "info", "warn", "error", "dpanic", "panic", and "fatal") | 	log level (one of "debug", "info", "warn", "error", "dpanic", "panic", and "fatal") | ||||||
|   | |||||||
| @@ -66,6 +66,10 @@ You will need to start a new shell for this setup to take effect. | |||||||
|  |  | ||||||
|  |  | ||||||
| .SH OPTIONS INHERITED FROM PARENT COMMANDS | .SH OPTIONS INHERITED FROM PARENT COMMANDS | ||||||
|  | .PP | ||||||
|  | \fB-l\fP, \fB--log-file\fP="" | ||||||
|  | 	path of a file to write logs to | ||||||
|  |  | ||||||
| .PP | .PP | ||||||
| \fB-d\fP, \fB--log-level\fP="info" | \fB-d\fP, \fB--log-level\fP="info" | ||||||
| 	log level (one of "debug", "info", "warn", "error", "dpanic", "panic", and "fatal") | 	log level (one of "debug", "info", "warn", "error", "dpanic", "panic", and "fatal") | ||||||
|   | |||||||
| @@ -24,6 +24,10 @@ See each sub-command's help for details on how to use the generated script. | |||||||
|  |  | ||||||
|  |  | ||||||
| .SH OPTIONS INHERITED FROM PARENT COMMANDS | .SH OPTIONS INHERITED FROM PARENT COMMANDS | ||||||
|  | .PP | ||||||
|  | \fB-l\fP, \fB--log-file\fP="" | ||||||
|  | 	path of a file to write logs to | ||||||
|  |  | ||||||
| .PP | .PP | ||||||
| \fB-d\fP, \fB--log-level\fP="info" | \fB-d\fP, \fB--log-level\fP="info" | ||||||
| 	log level (one of "debug", "info", "warn", "error", "dpanic", "panic", and "fatal") | 	log level (one of "debug", "info", "warn", "error", "dpanic", "panic", and "fatal") | ||||||
|   | |||||||
| @@ -62,7 +62,7 @@ Start the daemon | |||||||
| 	interval netween STUN keepalives | 	interval netween STUN keepalives | ||||||
|  |  | ||||||
| .PP | .PP | ||||||
| \fB-l\fP, \fB--ice-lite\fP[=false] | \fB-L\fP, \fB--ice-lite\fP[=false] | ||||||
| 	lite agents do not perform connectivity check and only provide host candidates | 	lite agents do not perform connectivity check and only provide host candidates | ||||||
|  |  | ||||||
| .PP | .PP | ||||||
| @@ -139,6 +139,10 @@ Start the daemon | |||||||
|  |  | ||||||
|  |  | ||||||
| .SH OPTIONS INHERITED FROM PARENT COMMANDS | .SH OPTIONS INHERITED FROM PARENT COMMANDS | ||||||
|  | .PP | ||||||
|  | \fB-l\fP, \fB--log-file\fP="" | ||||||
|  | 	path of a file to write logs to | ||||||
|  |  | ||||||
| .PP | .PP | ||||||
| \fB-d\fP, \fB--log-level\fP="info" | \fB-d\fP, \fB--log-level\fP="info" | ||||||
| 	log level (one of "debug", "info", "warn", "error", "dpanic", "panic", and "fatal") | 	log level (one of "debug", "info", "warn", "error", "dpanic", "panic", and "fatal") | ||||||
|   | |||||||
| @@ -27,6 +27,10 @@ Monitor the WICE daemon for events | |||||||
|  |  | ||||||
|  |  | ||||||
| .SH OPTIONS INHERITED FROM PARENT COMMANDS | .SH OPTIONS INHERITED FROM PARENT COMMANDS | ||||||
|  | .PP | ||||||
|  | \fB-l\fP, \fB--log-file\fP="" | ||||||
|  | 	path of a file to write logs to | ||||||
|  |  | ||||||
| .PP | .PP | ||||||
| \fB-d\fP, \fB--log-level\fP="info" | \fB-d\fP, \fB--log-level\fP="info" | ||||||
| 	log level (one of "debug", "info", "warn", "error", "dpanic", "panic", and "fatal") | 	log level (one of "debug", "info", "warn", "error", "dpanic", "panic", and "fatal") | ||||||
|   | |||||||
| @@ -22,11 +22,15 @@ Start gRPC signaling server | |||||||
| 	help for signal | 	help for signal | ||||||
|  |  | ||||||
| .PP | .PP | ||||||
| \fB-l\fP, \fB--listen\fP=":443" | \fB-L\fP, \fB--listen\fP=":443" | ||||||
| 	listen address | 	listen address | ||||||
|  |  | ||||||
|  |  | ||||||
| .SH OPTIONS INHERITED FROM PARENT COMMANDS | .SH OPTIONS INHERITED FROM PARENT COMMANDS | ||||||
|  | .PP | ||||||
|  | \fB-l\fP, \fB--log-file\fP="" | ||||||
|  | 	path of a file to write logs to | ||||||
|  |  | ||||||
| .PP | .PP | ||||||
| \fB-d\fP, \fB--log-level\fP="info" | \fB-d\fP, \fB--log-level\fP="info" | ||||||
| 	log level (one of "debug", "info", "warn", "error", "dpanic", "panic", and "fatal") | 	log level (one of "debug", "info", "warn", "error", "dpanic", "panic", and "fatal") | ||||||
|   | |||||||
| @@ -27,6 +27,10 @@ Shutdown the WICE daemon | |||||||
|  |  | ||||||
|  |  | ||||||
| .SH OPTIONS INHERITED FROM PARENT COMMANDS | .SH OPTIONS INHERITED FROM PARENT COMMANDS | ||||||
|  | .PP | ||||||
|  | \fB-l\fP, \fB--log-file\fP="" | ||||||
|  | 	path of a file to write logs to | ||||||
|  |  | ||||||
| .PP | .PP | ||||||
| \fB-d\fP, \fB--log-level\fP="info" | \fB-d\fP, \fB--log-level\fP="info" | ||||||
| 	log level (one of "debug", "info", "warn", "error", "dpanic", "panic", and "fatal") | 	log level (one of "debug", "info", "warn", "error", "dpanic", "panic", and "fatal") | ||||||
|   | |||||||
| @@ -27,6 +27,10 @@ Synchronizes the internal daemon state with the state of the Wireguard interface | |||||||
|  |  | ||||||
|  |  | ||||||
| .SH OPTIONS INHERITED FROM PARENT COMMANDS | .SH OPTIONS INHERITED FROM PARENT COMMANDS | ||||||
|  | .PP | ||||||
|  | \fB-l\fP, \fB--log-file\fP="" | ||||||
|  | 	path of a file to write logs to | ||||||
|  |  | ||||||
| .PP | .PP | ||||||
| \fB-d\fP, \fB--log-level\fP="info" | \fB-d\fP, \fB--log-level\fP="info" | ||||||
| 	log level (one of "debug", "info", "warn", "error", "dpanic", "panic", and "fatal") | 	log level (one of "debug", "info", "warn", "error", "dpanic", "panic", and "fatal") | ||||||
|   | |||||||
| @@ -23,6 +23,10 @@ Generates a new private key and writes it to stdout | |||||||
|  |  | ||||||
|  |  | ||||||
| .SH OPTIONS INHERITED FROM PARENT COMMANDS | .SH OPTIONS INHERITED FROM PARENT COMMANDS | ||||||
|  | .PP | ||||||
|  | \fB-l\fP, \fB--log-file\fP="" | ||||||
|  | 	path of a file to write logs to | ||||||
|  |  | ||||||
| .PP | .PP | ||||||
| \fB-d\fP, \fB--log-level\fP="info" | \fB-d\fP, \fB--log-level\fP="info" | ||||||
| 	log level (one of "debug", "info", "warn", "error", "dpanic", "panic", and "fatal") | 	log level (one of "debug", "info", "warn", "error", "dpanic", "panic", and "fatal") | ||||||
|   | |||||||
| @@ -23,6 +23,10 @@ Generates a new preshared key and writes it to stdout | |||||||
|  |  | ||||||
|  |  | ||||||
| .SH OPTIONS INHERITED FROM PARENT COMMANDS | .SH OPTIONS INHERITED FROM PARENT COMMANDS | ||||||
|  | .PP | ||||||
|  | \fB-l\fP, \fB--log-file\fP="" | ||||||
|  | 	path of a file to write logs to | ||||||
|  |  | ||||||
| .PP | .PP | ||||||
| \fB-d\fP, \fB--log-level\fP="info" | \fB-d\fP, \fB--log-level\fP="info" | ||||||
| 	log level (one of "debug", "info", "warn", "error", "dpanic", "panic", and "fatal") | 	log level (one of "debug", "info", "warn", "error", "dpanic", "panic", and "fatal") | ||||||
|   | |||||||
| @@ -23,6 +23,10 @@ Reads a private key from stdin and writes a public key to stdout | |||||||
|  |  | ||||||
|  |  | ||||||
| .SH OPTIONS INHERITED FROM PARENT COMMANDS | .SH OPTIONS INHERITED FROM PARENT COMMANDS | ||||||
|  | .PP | ||||||
|  | \fB-l\fP, \fB--log-file\fP="" | ||||||
|  | 	path of a file to write logs to | ||||||
|  |  | ||||||
| .PP | .PP | ||||||
| \fB-d\fP, \fB--log-level\fP="info" | \fB-d\fP, \fB--log-level\fP="info" | ||||||
| 	log level (one of "debug", "info", "warn", "error", "dpanic", "panic", and "fatal") | 	log level (one of "debug", "info", "warn", "error", "dpanic", "panic", and "fatal") | ||||||
|   | |||||||
| @@ -27,6 +27,10 @@ Shows the current configuration and device information | |||||||
|  |  | ||||||
|  |  | ||||||
| .SH OPTIONS INHERITED FROM PARENT COMMANDS | .SH OPTIONS INHERITED FROM PARENT COMMANDS | ||||||
|  | .PP | ||||||
|  | \fB-l\fP, \fB--log-file\fP="" | ||||||
|  | 	path of a file to write logs to | ||||||
|  |  | ||||||
| .PP | .PP | ||||||
| \fB-d\fP, \fB--log-level\fP="info" | \fB-d\fP, \fB--log-level\fP="info" | ||||||
| 	log level (one of "debug", "info", "warn", "error", "dpanic", "panic", and "fatal") | 	log level (one of "debug", "info", "warn", "error", "dpanic", "panic", and "fatal") | ||||||
|   | |||||||
| @@ -23,6 +23,10 @@ Wireguard commands | |||||||
|  |  | ||||||
|  |  | ||||||
| .SH OPTIONS INHERITED FROM PARENT COMMANDS | .SH OPTIONS INHERITED FROM PARENT COMMANDS | ||||||
|  | .PP | ||||||
|  | \fB-l\fP, \fB--log-file\fP="" | ||||||
|  | 	path of a file to write logs to | ||||||
|  |  | ||||||
| .PP | .PP | ||||||
| \fB-d\fP, \fB--log-level\fP="info" | \fB-d\fP, \fB--log-level\fP="info" | ||||||
| 	log level (one of "debug", "info", "warn", "error", "dpanic", "panic", and "fatal") | 	log level (one of "debug", "info", "warn", "error", "dpanic", "panic", and "fatal") | ||||||
|   | |||||||
| @@ -21,6 +21,10 @@ Wireguard Interactive Connectitivty Establishment | |||||||
| \fB-h\fP, \fB--help\fP[=false] | \fB-h\fP, \fB--help\fP[=false] | ||||||
| 	help for wice | 	help for wice | ||||||
|  |  | ||||||
|  | .PP | ||||||
|  | \fB-l\fP, \fB--log-file\fP="" | ||||||
|  | 	path of a file to write logs to | ||||||
|  |  | ||||||
| .PP | .PP | ||||||
| \fB-d\fP, \fB--log-level\fP="info" | \fB-d\fP, \fB--log-level\fP="info" | ||||||
| 	log level (one of "debug", "info", "warn", "error", "dpanic", "panic", and "fatal") | 	log level (one of "debug", "info", "warn", "error", "dpanic", "panic", and "fatal") | ||||||
| @@ -28,4 +32,4 @@ Wireguard Interactive Connectitivty Establishment | |||||||
|  |  | ||||||
| .SH SEE ALSO | .SH SEE ALSO | ||||||
| .PP | .PP | ||||||
| \fBwice-completion(3)\fP, \fBwice-daemon(3)\fP, \fBwice-monitor(3)\fP, \fBwice-signal(3)\fP, \fBwice-stop(3)\fP, \fBwice-sync(3)\fP, \fBwice-wg(3)\fP | \fBwice-completion(3)\fP, \fBwice-daemon(3)\fP, \fBwice-interface(3)\fP, \fBwice-monitor(3)\fP, \fBwice-peer(3)\fP, \fBwice-signal(3)\fP, \fBwice-stop(3)\fP, \fBwice-sync(3)\fP, \fBwice-wg(3)\fP | ||||||
|   | |||||||
| @@ -14,6 +14,7 @@ wice [flags] | |||||||
|  |  | ||||||
| ``` | ``` | ||||||
|   -h, --help               help for wice |   -h, --help               help for wice | ||||||
|  |   -l, --log-file string    path of a file to write logs to | ||||||
|   -d, --log-level string   log level (one of "debug", "info", "warn", "error", "dpanic", "panic", and "fatal") (default "info") |   -d, --log-level string   log level (one of "debug", "info", "warn", "error", "dpanic", "panic", and "fatal") (default "info") | ||||||
| ``` | ``` | ||||||
|  |  | ||||||
| @@ -21,7 +22,9 @@ wice [flags] | |||||||
|  |  | ||||||
| * [wice completion](wice_completion.md)	 - Generate the autocompletion script for the specified shell | * [wice completion](wice_completion.md)	 - Generate the autocompletion script for the specified shell | ||||||
| * [wice daemon](wice_daemon.md)	 - Start the daemon | * [wice daemon](wice_daemon.md)	 - Start the daemon | ||||||
|  | * [wice interface](wice_interface.md)	 - Manage Wireguard interfaces | ||||||
| * [wice monitor](wice_monitor.md)	 - Monitor the WICE daemon for events | * [wice monitor](wice_monitor.md)	 - Monitor the WICE daemon for events | ||||||
|  | * [wice peer](wice_peer.md)	 - Manage Wireguard peers | ||||||
| * [wice signal](wice_signal.md)	 - Start gRPC signaling server | * [wice signal](wice_signal.md)	 - Start gRPC signaling server | ||||||
| * [wice stop](wice_stop.md)	 - Shutdown the WICE daemon | * [wice stop](wice_stop.md)	 - Shutdown the WICE daemon | ||||||
| * [wice sync](wice_sync.md)	 - Synchronize interfaces | * [wice sync](wice_sync.md)	 - Synchronize interfaces | ||||||
|   | |||||||
| @@ -17,6 +17,7 @@ See each sub-command's help for details on how to use the generated script. | |||||||
| ### Options inherited from parent commands | ### Options inherited from parent commands | ||||||
|  |  | ||||||
| ``` | ``` | ||||||
|  |   -l, --log-file string    path of a file to write logs to | ||||||
|   -d, --log-level string   log level (one of "debug", "info", "warn", "error", "dpanic", "panic", and "fatal") (default "info") |   -d, --log-level string   log level (one of "debug", "info", "warn", "error", "dpanic", "panic", and "fatal") (default "info") | ||||||
| ``` | ``` | ||||||
|  |  | ||||||
|   | |||||||
| @@ -40,6 +40,7 @@ wice completion bash | |||||||
| ### Options inherited from parent commands | ### Options inherited from parent commands | ||||||
|  |  | ||||||
| ``` | ``` | ||||||
|  |   -l, --log-file string    path of a file to write logs to | ||||||
|   -d, --log-level string   log level (one of "debug", "info", "warn", "error", "dpanic", "panic", and "fatal") (default "info") |   -d, --log-level string   log level (one of "debug", "info", "warn", "error", "dpanic", "panic", and "fatal") (default "info") | ||||||
| ``` | ``` | ||||||
|  |  | ||||||
|   | |||||||
| @@ -31,6 +31,7 @@ wice completion fish [flags] | |||||||
| ### Options inherited from parent commands | ### Options inherited from parent commands | ||||||
|  |  | ||||||
| ``` | ``` | ||||||
|  |   -l, --log-file string    path of a file to write logs to | ||||||
|   -d, --log-level string   log level (one of "debug", "info", "warn", "error", "dpanic", "panic", and "fatal") (default "info") |   -d, --log-level string   log level (one of "debug", "info", "warn", "error", "dpanic", "panic", and "fatal") (default "info") | ||||||
| ``` | ``` | ||||||
|  |  | ||||||
|   | |||||||
| @@ -28,6 +28,7 @@ wice completion powershell [flags] | |||||||
| ### Options inherited from parent commands | ### Options inherited from parent commands | ||||||
|  |  | ||||||
| ``` | ``` | ||||||
|  |   -l, --log-file string    path of a file to write logs to | ||||||
|   -d, --log-level string   log level (one of "debug", "info", "warn", "error", "dpanic", "panic", and "fatal") (default "info") |   -d, --log-level string   log level (one of "debug", "info", "warn", "error", "dpanic", "panic", and "fatal") (default "info") | ||||||
| ``` | ``` | ||||||
|  |  | ||||||
|   | |||||||
| @@ -38,6 +38,7 @@ wice completion zsh [flags] | |||||||
| ### Options inherited from parent commands | ### Options inherited from parent commands | ||||||
|  |  | ||||||
| ``` | ``` | ||||||
|  |   -l, --log-file string    path of a file to write logs to | ||||||
|   -d, --log-level string   log level (one of "debug", "info", "warn", "error", "dpanic", "panic", and "fatal") (default "info") |   -d, --log-level string   log level (one of "debug", "info", "warn", "error", "dpanic", "panic", and "fatal") (default "info") | ||||||
| ``` | ``` | ||||||
|  |  | ||||||
|   | |||||||
| @@ -20,7 +20,7 @@ wice daemon [interfaces...] [flags] | |||||||
|   -k, --ice-insecure-skip-verify           skip verification of TLS certificates for secure STUN/TURN servers |   -k, --ice-insecure-skip-verify           skip verification of TLS certificates for secure STUN/TURN servers | ||||||
|       --ice-interface-filter string        regex for filtering local interfaces for ICE candidate gathering (e.g. "eth[0-9]+") (default ".*") |       --ice-interface-filter string        regex for filtering local interfaces for ICE candidate gathering (e.g. "eth[0-9]+") (default ".*") | ||||||
|       --ice-keepalive-interval duration    interval netween STUN keepalives (default 2s) |       --ice-keepalive-interval duration    interval netween STUN keepalives (default 2s) | ||||||
|   -l, --ice-lite                           lite agents do not perform connectivity check and only provide host candidates |   -L, --ice-lite                           lite agents do not perform connectivity check and only provide host candidates | ||||||
|       --ice-max-binding-requests uint16    maximum number of binding request before considering a pair failed (default 7) |       --ice-max-binding-requests uint16    maximum number of binding request before considering a pair failed (default 7) | ||||||
|   -m, --ice-mdns                           enable local Multicast DNS discovery |   -m, --ice-mdns                           enable local Multicast DNS discovery | ||||||
|       --ice-nat-1to1-ip ipSlice            IP addresses which will be added as local server reflexive candidates (default []) |       --ice-nat-1to1-ip ipSlice            IP addresses which will be added as local server reflexive candidates (default []) | ||||||
| @@ -44,6 +44,7 @@ wice daemon [interfaces...] [flags] | |||||||
| ### Options inherited from parent commands | ### Options inherited from parent commands | ||||||
|  |  | ||||||
| ``` | ``` | ||||||
|  |   -l, --log-file string    path of a file to write logs to | ||||||
|   -d, --log-level string   log level (one of "debug", "info", "warn", "error", "dpanic", "panic", and "fatal") (default "info") |   -d, --log-level string   log level (one of "debug", "info", "warn", "error", "dpanic", "panic", and "fatal") (default "info") | ||||||
| ``` | ``` | ||||||
|  |  | ||||||
|   | |||||||
| @@ -16,6 +16,7 @@ wice monitor [flags] | |||||||
| ### Options inherited from parent commands | ### Options inherited from parent commands | ||||||
|  |  | ||||||
| ``` | ``` | ||||||
|  |   -l, --log-file string    path of a file to write logs to | ||||||
|   -d, --log-level string   log level (one of "debug", "info", "warn", "error", "dpanic", "panic", and "fatal") (default "info") |   -d, --log-level string   log level (one of "debug", "info", "warn", "error", "dpanic", "panic", and "fatal") (default "info") | ||||||
| ``` | ``` | ||||||
|  |  | ||||||
|   | |||||||
| @@ -10,12 +10,13 @@ wice signal [flags] | |||||||
|  |  | ||||||
| ``` | ``` | ||||||
|   -h, --help            help for signal |   -h, --help            help for signal | ||||||
|   -l, --listen string   listen address (default ":443") |   -L, --listen string   listen address (default ":443") | ||||||
| ``` | ``` | ||||||
|  |  | ||||||
| ### Options inherited from parent commands | ### Options inherited from parent commands | ||||||
|  |  | ||||||
| ``` | ``` | ||||||
|  |   -l, --log-file string    path of a file to write logs to | ||||||
|   -d, --log-level string   log level (one of "debug", "info", "warn", "error", "dpanic", "panic", and "fatal") (default "info") |   -d, --log-level string   log level (one of "debug", "info", "warn", "error", "dpanic", "panic", and "fatal") (default "info") | ||||||
| ``` | ``` | ||||||
|  |  | ||||||
|   | |||||||
| @@ -16,6 +16,7 @@ wice stop [flags] | |||||||
| ### Options inherited from parent commands | ### Options inherited from parent commands | ||||||
|  |  | ||||||
| ``` | ``` | ||||||
|  |   -l, --log-file string    path of a file to write logs to | ||||||
|   -d, --log-level string   log level (one of "debug", "info", "warn", "error", "dpanic", "panic", and "fatal") (default "info") |   -d, --log-level string   log level (one of "debug", "info", "warn", "error", "dpanic", "panic", and "fatal") (default "info") | ||||||
| ``` | ``` | ||||||
|  |  | ||||||
|   | |||||||
| @@ -20,6 +20,7 @@ wice sync [flags] | |||||||
| ### Options inherited from parent commands | ### Options inherited from parent commands | ||||||
|  |  | ||||||
| ``` | ``` | ||||||
|  |   -l, --log-file string    path of a file to write logs to | ||||||
|   -d, --log-level string   log level (one of "debug", "info", "warn", "error", "dpanic", "panic", and "fatal") (default "info") |   -d, --log-level string   log level (one of "debug", "info", "warn", "error", "dpanic", "panic", and "fatal") (default "info") | ||||||
| ``` | ``` | ||||||
|  |  | ||||||
|   | |||||||
| @@ -11,6 +11,7 @@ Wireguard commands | |||||||
| ### Options inherited from parent commands | ### Options inherited from parent commands | ||||||
|  |  | ||||||
| ``` | ``` | ||||||
|  |   -l, --log-file string    path of a file to write logs to | ||||||
|   -d, --log-level string   log level (one of "debug", "info", "warn", "error", "dpanic", "panic", and "fatal") (default "info") |   -d, --log-level string   log level (one of "debug", "info", "warn", "error", "dpanic", "panic", and "fatal") (default "info") | ||||||
| ``` | ``` | ||||||
|  |  | ||||||
|   | |||||||
| @@ -15,6 +15,7 @@ wice wg genkey [flags] | |||||||
| ### Options inherited from parent commands | ### Options inherited from parent commands | ||||||
|  |  | ||||||
| ``` | ``` | ||||||
|  |   -l, --log-file string    path of a file to write logs to | ||||||
|   -d, --log-level string   log level (one of "debug", "info", "warn", "error", "dpanic", "panic", and "fatal") (default "info") |   -d, --log-level string   log level (one of "debug", "info", "warn", "error", "dpanic", "panic", and "fatal") (default "info") | ||||||
| ``` | ``` | ||||||
|  |  | ||||||
|   | |||||||
| @@ -15,6 +15,7 @@ wice wg genpsk [flags] | |||||||
| ### Options inherited from parent commands | ### Options inherited from parent commands | ||||||
|  |  | ||||||
| ``` | ``` | ||||||
|  |   -l, --log-file string    path of a file to write logs to | ||||||
|   -d, --log-level string   log level (one of "debug", "info", "warn", "error", "dpanic", "panic", and "fatal") (default "info") |   -d, --log-level string   log level (one of "debug", "info", "warn", "error", "dpanic", "panic", and "fatal") (default "info") | ||||||
| ``` | ``` | ||||||
|  |  | ||||||
|   | |||||||
| @@ -15,6 +15,7 @@ wice wg pubkey [flags] | |||||||
| ### Options inherited from parent commands | ### Options inherited from parent commands | ||||||
|  |  | ||||||
| ``` | ``` | ||||||
|  |   -l, --log-file string    path of a file to write logs to | ||||||
|   -d, --log-level string   log level (one of "debug", "info", "warn", "error", "dpanic", "panic", and "fatal") (default "info") |   -d, --log-level string   log level (one of "debug", "info", "warn", "error", "dpanic", "panic", and "fatal") (default "info") | ||||||
| ``` | ``` | ||||||
|  |  | ||||||
|   | |||||||
| @@ -16,6 +16,7 @@ wice wg show [flags] | |||||||
| ### Options inherited from parent commands | ### Options inherited from parent commands | ||||||
|  |  | ||||||
| ``` | ``` | ||||||
|  |   -l, --log-file string    path of a file to write logs to | ||||||
|   -d, --log-level string   log level (one of "debug", "info", "warn", "error", "dpanic", "panic", and "fatal") (default "info") |   -d, --log-level string   log level (one of "debug", "info", "warn", "error", "dpanic", "panic", and "fatal") (default "info") | ||||||
| ``` | ``` | ||||||
|  |  | ||||||
|   | |||||||
| @@ -19,7 +19,7 @@ import ( | |||||||
| 	"riasc.eu/wice/internal/log" | 	"riasc.eu/wice/internal/log" | ||||||
| ) | ) | ||||||
|  |  | ||||||
| func SetupLogging(level zapcore.Level) *zap.Logger { | func SetupLogging(level zapcore.Level, file string) *zap.Logger { | ||||||
| 	cfg := zap.NewDevelopmentConfig() | 	cfg := zap.NewDevelopmentConfig() | ||||||
|  |  | ||||||
| 	cfg.Level = zap.NewAtomicLevelAt(level) | 	cfg.Level = zap.NewAtomicLevelAt(level) | ||||||
| @@ -27,6 +27,10 @@ func SetupLogging(level zapcore.Level) *zap.Logger { | |||||||
| 	cfg.DisableCaller = true | 	cfg.DisableCaller = true | ||||||
| 	cfg.DisableStacktrace = true | 	cfg.DisableStacktrace = true | ||||||
|  |  | ||||||
|  | 	if file != "" { | ||||||
|  | 		cfg.OutputPaths = append(cfg.OutputPaths, file) | ||||||
|  | 	} | ||||||
|  |  | ||||||
| 	logger, err := cfg.Build() | 	logger, err := cfg.Build() | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		panic(err) | 		panic(err) | ||||||
| @@ -43,6 +47,7 @@ func SetupLogging(level zapcore.Level) *zap.Logger { | |||||||
| 	glogger := logger.Named("grpc") | 	glogger := logger.Named("grpc") | ||||||
| 	grpclog.SetLoggerV2(log.NewGRPCLogger(glogger)) | 	grpclog.SetLoggerV2(log.NewGRPCLogger(glogger)) | ||||||
|  |  | ||||||
|  | 	zap.RedirectStdLog(logger) | ||||||
| 	zap.ReplaceGlobals(logger) | 	zap.ReplaceGlobals(logger) | ||||||
|  |  | ||||||
| 	return logger | 	return logger | ||||||
|   | |||||||
| @@ -153,7 +153,7 @@ func NewConfig(flags *pflag.FlagSet) *Config { | |||||||
|  |  | ||||||
| 	flags.Uint16Var(&cfg.icePortMin, "ice-port-min", 0, "minimum port for allocation policy (range: 0-65535)") | 	flags.Uint16Var(&cfg.icePortMin, "ice-port-min", 0, "minimum port for allocation policy (range: 0-65535)") | ||||||
| 	flags.Uint16Var(&cfg.icePortMax, "ice-port-max", 0, "maximum port for allocation policy (range: 0-65535)") | 	flags.Uint16Var(&cfg.icePortMax, "ice-port-max", 0, "maximum port for allocation policy (range: 0-65535)") | ||||||
| 	flags.BoolVarP(&cfg.iceLite, "ice-lite", "l", false, "lite agents do not perform connectivity check and only provide host candidates") | 	flags.BoolVarP(&cfg.iceLite, "ice-lite", "L", false, "lite agents do not perform connectivity check and only provide host candidates") | ||||||
| 	flags.BoolVarP(&cfg.iceMdns, "ice-mdns", "m", false, "enable local Multicast DNS discovery") | 	flags.BoolVarP(&cfg.iceMdns, "ice-mdns", "m", false, "enable local Multicast DNS discovery") | ||||||
| 	flags.Uint16Var(&cfg.iceMaxBindingRequests, "ice-max-binding-requests", defaultMaxBindingRequests, "maximum number of binding request before considering a pair failed") | 	flags.Uint16Var(&cfg.iceMaxBindingRequests, "ice-max-binding-requests", defaultMaxBindingRequests, "maximum number of binding request before considering a pair failed") | ||||||
| 	flags.BoolVarP(&cfg.iceInsecureSkipVerify, "ice-insecure-skip-verify", "k", false, "skip verification of TLS certificates for secure STUN/TURN servers") | 	flags.BoolVarP(&cfg.iceInsecureSkipVerify, "ice-insecure-skip-verify", "k", false, "skip verification of TLS certificates for secure STUN/TURN servers") | ||||||
|   | |||||||
| @@ -7,7 +7,6 @@ import ( | |||||||
| 	"strings" | 	"strings" | ||||||
|  |  | ||||||
| 	"github.com/pion/ice/v2" | 	"github.com/pion/ice/v2" | ||||||
| 	"go.uber.org/zap" |  | ||||||
| 	"riasc.eu/wice/pkg/proxy" | 	"riasc.eu/wice/pkg/proxy" | ||||||
| ) | ) | ||||||
|  |  | ||||||
| @@ -144,16 +143,6 @@ func (pt *proxyType) Set(value string) error { | |||||||
| 	return err | 	return err | ||||||
| } | } | ||||||
|  |  | ||||||
| type logLevel struct{ zap.AtomicLevel } |  | ||||||
|  |  | ||||||
| func (ll *logLevel) Type() string { |  | ||||||
| 	return "string" |  | ||||||
| } |  | ||||||
|  |  | ||||||
| func (ll *logLevel) Set(value string) error { |  | ||||||
| 	return ll.UnmarshalText([]byte(value)) |  | ||||||
| } |  | ||||||
|  |  | ||||||
| type regex struct{ *regexp.Regexp } | type regex struct{ *regexp.Regexp } | ||||||
|  |  | ||||||
| func (re *regex) Type() string { | func (re *regex) Type() string { | ||||||
|   | |||||||
| @@ -10,7 +10,7 @@ import ( | |||||||
|  |  | ||||||
| func Main(m *testing.M) { | func Main(m *testing.M) { | ||||||
| 	internal.SetupRand() | 	internal.SetupRand() | ||||||
| 	logger := internal.SetupLogging(zapcore.DebugLevel) | 	logger := internal.SetupLogging(zapcore.DebugLevel, "logs/test.log") | ||||||
| 	defer logger.Sync() | 	defer logger.Sync() | ||||||
|  |  | ||||||
| 	os.Exit(m.Run()) | 	os.Exit(m.Run()) | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Steffen Vogel
					Steffen Vogel