Skip to content

Commit

Permalink
feat: set package log level with logging trait
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Olsiak committed Oct 23, 2023
1 parent d089fea commit d462365
Showing 1 changed file with 21 additions and 14 deletions.
35 changes: 21 additions & 14 deletions pkg/trait/logging_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -214,30 +214,37 @@ func TestJsonLoggingTrait(t *testing.T) {
assert.NotEmpty(t, env.ExecutedTraits)
}

func TestLoggingCategory(t *testing.T) {
func TestSingleLoggingCategory(t *testing.T) {
env := createLoggingTestEnv(t, true, true, false, "TRACE", "%d{HH:mm:ss} %-5p (%t) %s%e%n", map[string]string{})
env.Integration.Spec.Traits = v1.Traits{
Logging: &traitv1.LoggingTrait{
Category: map[string]string{"org.test": "debug"},
},
}
err := NewLoggingTestCatalog().apply(env)
assert.Nil(t, err)

envVarQuarkusLogCategoryTestPackageName := "QUARKUS_LOG_CATEGORY_ORG_TEST_LEVEL"
envVarQuarkusLogCategoryTestPackageValue := "DEBUG"
quarkusOrgPackage := false
testEnvVar := corev1.EnvVar{"QUARKUS_LOG_CATEGORY_ORG_TEST_LEVEL", "DEBUG", nil}
assert.Contains(t, env.EnvVars, testEnvVar)
}

func TestLoggingCategories(t *testing.T) {
env := createLoggingTestEnv(t, true, true, false, "TRACE", "%d{HH:mm:ss} %-5p (%t) %s%e%n", map[string]string{})
env.Integration.Spec.Traits = v1.Traits{
Logging: &traitv1.LoggingTrait{
Category: map[string]string{"org.test": "debug", "org.jboss.resteasy": "debug"},
},
}
err := NewLoggingTestCatalog().apply(env)

assert.Nil(t, err)

for _, e := range env.EnvVars {
t.Log("Key:" + e.Name)
if e.Name == envVarQuarkusLogCategoryTestPackageName {
t.Log("Value: " + e.Value)
if e.Value == envVarQuarkusLogCategoryTestPackageValue {
quarkusOrgPackage = true
}
}
testEnvVars := []corev1.EnvVar{
corev1.EnvVar{"QUARKUS_LOG_CATEGORY_ORG_TEST_LEVEL", "DEBUG", nil},
corev1.EnvVar{"QUARKUS_LOG_CATEGORY_ORG_JBOSS_RESTEASY_LEVEL", "DEBUG", nil},
}
assert.True(t, quarkusOrgPackage)

for _, v := range testEnvVars {
assert.Contains(t, env.EnvVars, v)
}

}

0 comments on commit d462365

Please sign in to comment.