@@ -15,8 +15,9 @@ import (
1515 "time"
1616
1717 "github.com/go-kit/log"
18- "github.com/grafana/alloy/internal/runtime/logging/level"
1918 yaml "gopkg.in/yaml.v2"
19+
20+ "github.com/grafana/alloy/internal/runtime/logging/level"
2021)
2122
2223const (
@@ -106,14 +107,15 @@ type LegacyFile struct {
106107// 2. There is a file at the legacy path and that it is valid yaml
107108func ConvertLegacyPositionsFile (legacyPath , newPath string , l log.Logger ) {
108109 legacyPositions := readLegacyFile (legacyPath , l )
109- // LegacyPositions did not exist or was invalid so return.
110+ // legacyPositions did not exist or was invalid so return.
110111 if legacyPositions == nil {
112+ level .Info (l ).Log ("msg" , "will not convert the legacy positions file as it is not valid or does not exist" , "legacy_path" , legacyPath )
111113 return
112114 }
113115 fi , err := os .Stat (newPath )
114116 // If the newpath exists, then don't convert.
115117 if err == nil && fi .Size () > 0 {
116- level .Info (l ).Log ("msg" , "new positions file already exists" , "path" , newPath )
118+ level .Info (l ).Log ("msg" , "will not convert the legacy positions file as the new positions file already exists" , "path" , newPath )
117119 return
118120 }
119121
@@ -125,11 +127,11 @@ func ConvertLegacyPositionsFile(legacyPath, newPath string, l log.Logger) {
125127 Labels : "{}" ,
126128 }] = v
127129 }
128- // After conversion remove the file.
129130 err = writePositionFile (newPath , newPositions )
130131 if err != nil {
131- level .Error (l ).Log ("msg" , "error writing new positions file from legacy" , "path" , newPath , "error" , err )
132+ level .Error (l ).Log ("msg" , "error writing new positions file converted from legacy" , "path" , newPath , "error" , err )
132133 }
134+ level .Info (l ).Log ("msg" , "successfully converted legacy positions file to the new format" , "path" , newPath , "legacy_path" , legacyPath )
133135}
134136
135137func readLegacyFile (legacyPath string , l log.Logger ) * LegacyFile {
0 commit comments