Add kubernetes objects aware logger with zap (#2179)

Using controller-runtime zap integration which is aware of Kubernetesobjects and logs only name+namespace of the object when complete runtime.Object compatible type is given to logger.

Signed-off-by: Sanket Sudake <sanketsudake@gmail.com>
This commit is contained in:
Sanket Sudake
2021-08-31 18:38:14 +05:30
committed by GitHub
parent f195975bda
commit a1cbce810e
13 changed files with 130 additions and 104 deletions
+5 -11
View File
@@ -17,28 +17,22 @@ limitations under the License.
package main
import (
"log"
"os"
"go.uber.org/zap"
"go.uber.org/zap/zapcore"
"github.com/fission/fission/cmd/builder/app"
"github.com/fission/fission/pkg/utils/loggerfactory"
"github.com/fission/fission/pkg/utils/profile"
)
// Usage: builder <shared volume path>
func main() {
profile.ProfileIfEnabled()
config := zap.NewProductionConfig()
config.EncoderConfig.EncodeTime = zapcore.ISO8601TimeEncoder
logger, err := config.Build()
if err != nil {
log.Fatalf("can't initialize zap logger: %v", err)
}
logger := loggerfactory.GetLogger()
defer logger.Sync()
profile.ProfileIfEnabled(logger)
shareVolume := os.Args[1]
if _, err := os.Stat(shareVolume); err != nil {
if os.IsNotExist(err) {
@@ -49,6 +43,6 @@ func main() {
}
}
err = app.Run(logger, shareVolume)
err := app.Run(logger, shareVolume)
logger.Error("error running builder", zap.Error(err))
}