Skip to content

Commit

Permalink
refactor(log): ingore error log when journal is disable
Browse files Browse the repository at this point in the history
There is no systemd and journal in our distribution, and when using ignition, many warning logs are printed. The changes in this PR will check if there is a journal in the current distribution, and if not, it will not pass the logs to the journal.

Notes: The distro Alpine has no journal. Add conditional to avoid failure due to logging method not being available.

Signed-off-by: Kevin Cui <[email protected]>
  • Loading branch information
BlackHole1 committed Oct 21, 2024
1 parent 9871e7c commit 34978b9
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion internal/exec/engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ func (e *Engine) acquireConfig(stageName string) (cfg types.Config, err error) {
cfg, err = e.acquireProviderConfig()

// if we've successfully fetched and cached the configs, log about them
if err == nil {
if err == nil && journal.Enabled() {
for _, cfgInfo := range e.State.FetchedConfigs {
if logerr := logStructuredJournalEntry(cfgInfo); logerr != nil {
e.Logger.Info("failed to log systemd journal entry: %v", logerr)
Expand Down

0 comments on commit 34978b9

Please sign in to comment.