~bayindirh/nudge

c46f7d91e94970f86ac94da70b65165c0587e689 — Hakan Bayindir 4 months ago 4779def
proj: Restart development.

- proj: Bump version to 0.3.0a1 to mark development start.
- feat: Add a small debug log line in printState function to show how many log targets are defined.
- refactor: Pass through gofmt.
2 files changed, 25 insertions(+), 13 deletions(-)

M CHANGELOG.md
M src/nudge.go
M CHANGELOG.md => CHANGELOG.md +7 -0
@@ 2,6 2,13 @@

**Note:** Please add newest entries on top. Use ISO date format YYYY-MM-DD and markdown formatting.

## 2023-10-15

- proj: Bump version to `0.3.0a1` to mark development start.
- feat: Add a small `debug` log line in `printState` function to show how many log targets are defined.
- refactor: Pass through `gofmt`.


## 2023-07-31

- proj: Version is changed to 0.2.0

M src/nudge.go => src/nudge.go +18 -13
@@ 118,7 118,7 @@ func applyDefaultConfiguration(runtimeConfiguration *RuntimeConfiguration, notif
	// Let's set defaults for the application itself, again where it makes sense.
	applicationName := strings.Split(os.Args[0], "/")
	runtimeConfiguration.applicationName = applicationName[len(applicationName)-1]
	runtimeConfiguration.version = "0.2.0"
	runtimeConfiguration.version = "0.3.0a1"
	runtimeConfiguration.dryrun = false
	runtimeConfiguration.logfilePaths = []string{"stdout"}
	runtimeConfiguration.logLevel = "warn"


@@ 338,7 338,8 @@ func printState(runtimeConfiguration *RuntimeConfiguration, notification *Notifi
	logger.Infof("Configuration file path: %s", runtimeConfiguration.configFilePath)
	logger.Infof("Pushover API key: %s", runtimeConfiguration.apiKey)
	logger.Infof("Pushover user key: %s", runtimeConfiguration.userKey)
	logger.Infof("Log file path: %s", runtimeConfiguration.logfilePaths)
	logger.Infof("Log file path(s): %s", runtimeConfiguration.logfilePaths)
	logger.Debugf("Total logging path count: %d", len(runtimeConfiguration.logfilePaths))
	logger.Infof("Current logging level is %s.", runtimeConfiguration.logLevel)
	logger.Infof("") // Leave an empty line.



@@ 412,6 413,7 @@ func main() {
	 *
	 * XXX: This JSON config part will be replaced with a programmatic block later.
	 */

	zapDefaultConfigJSON := []byte(`{
	  "level": "debug",
	  "encoding": "console",


@@ 427,21 429,22 @@ func main() {
	}`)

	var zapRuntimeConfig zap.Config

	if err := json.Unmarshal(zapDefaultConfigJSON, &zapRuntimeConfig); err != nil {
		panic(err)
	}
	

	/*
	 * We build the logger with the default configuration before everything else.
	 * We know that the config is sane, because it's hardcoded. We're using built-in
	 * defaults at that point.
	 */
	zapDefaultAtomicLevel, err := zap.ParseAtomicLevel(runtimeConfiguration.logLevel)
	

	if err != nil {
		panic (err)
		panic(err)
	}
	

	zapRuntimeConfig.Level = zapDefaultAtomicLevel
	logger := zap.Must(zapRuntimeConfig.Build())



@@ 467,27 470,29 @@ func main() {
	flag.Visit(func(setFlag *flag.Flag) {
		setFlags = append(setFlags, setFlag.Name)
	})
	

	// Then I can apply the set flags.
	applyFlags(&setFlags, &flagStorage, &runtimeConfiguration, &notificationToSend, sugaredLogger)
	

	// Run all the configuration checks and issue relevant warnings or errors.
	// TODO: Is here the best place to call this? Take a look before releasing.
	checkConfigurationSanity(&notificationToSend, &runtimeConfiguration, &validConfigurationOptions, sugaredLogger)

	// This is the demarcation line between config reading and starting doing things.
	

	// TODO: Reconfigure Zap with new logging paths at this point.

	// Let's try to change the logging level of our current logger.
	newLogLevelJSON := []byte(runtimeConfiguration.logLevel)
	

	err = zapRuntimeConfig.Level.UnmarshalText(newLogLevelJSON)
	

	if err != nil {
		sugaredLogger.Panicf("Supplied log level %s is invalid, exiting.", runtimeConfiguration.logLevel)
	}
	

	sugaredLogger.Debug("Logging level is changed to %s.", runtimeConfiguration.logLevel)
	

	// Check whether our version is asked or not.
	// Version info shall always return clean.
	if flagStorage.versionRequested {