Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion os-eap7-launch/added/launch/configure_logger_category.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ add_logger_category() {
logger=$(echo "$i" | sed 's/ //g')
logger_category=$(echo $logger | awk -F':' '{print $1}')
logger_level=$(echo $logger | awk -F':' '{print $2}')
if [[ ! "${allowed_log_levels[@]}" =~ " ${logger_level}" ]]; then
if [[ ! "${allowed_log_levels[@]}" =~ "${logger_level}" ]]; then
log_warning "Log Level ${logger_level} is not allowed, the allowed levels are ${allowed_log_levels[@]}"
else
log_info "Configuring logger category ${logger_category} with level ${logger_level:-FINE}"
Expand Down
50 changes: 50 additions & 0 deletions os-eap7-launch/tests/bats/logging/configure-logging-category.bats
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,38 @@ EOF
[ "${result}" = "${expected}" ]
}

@test "Add ALL logger category" {
#this is the return of xmllint --xpath "//*[local-name()='subsystem']//*[local-name()='logger'][@category='com.my.package']" $CONFIG_FILE
expected=$(cat <<EOF
<logger category="com.my.package"><level name="ALL"/></logger>
EOF
)
LOGGER_CATEGORIES=com.my.package:ALL
run add_logger_category
result=$(xmllint --xpath "//*[local-name()='subsystem']//*[local-name()='logger'][@category='com.my.package']" $CONFIG_FILE)
result="$(echo "<test>${result}</test>" | sed 's|\\n||g' | xmllint --format --noblanks -)"
expected=$(echo "<test>${expected}</test>" | sed 's|\\n||g' | xmllint --format --noblanks -)
echo "Expected: ${expected}"
echo "Result: ${result}"
[ "${result}" = "${expected}" ]
}

@test "Add TRACE logger category" {
#this is the return of xmllint --xpath "//*[local-name()='subsystem']//*[local-name()='logger'][@category='com.my.package']" $CONFIG_FILE
expected=$(cat <<EOF
<logger category="com.my.package"><level name="TRACE"/></logger>
EOF
)
LOGGER_CATEGORIES=com.my.package:TRACE
run add_logger_category
result=$(xmllint --xpath "//*[local-name()='subsystem']//*[local-name()='logger'][@category='com.my.package']" $CONFIG_FILE)
result="$(echo "<test>${result}</test>" | sed 's|\\n||g' | xmllint --format --noblanks -)"
expected=$(echo "<test>${expected}</test>" | sed 's|\\n||g' | xmllint --format --noblanks -)
echo "Expected: ${expected}"
echo "Result: ${result}"
[ "${result}" = "${expected}" ]
}

@test "Add 2 logger categories" {
#this is the return of xmllint --xpath "//*[local-name()='subsystem']//*[local-name()='logger']" $CONFIG_FILE
expected=$(cat <<EOF
Expand Down Expand Up @@ -106,6 +138,24 @@ EOF
[ "${result}" = "${expected}" ]
}

@test "Add 3 logger categories with ALL and with spaces" {
#this is the return of xmllint --xpath "//*[local-name()='subsystem']//*[local-name()='logger'][@category='com.my.package' or @category='my.other.package' or @category='my.another.package']" $CONFIG_FILE '
expected=$(cat <<EOF
<logger category="com.my.package"><level name="ALL"/></logger>
<logger category="my.other.package"><level name="ERROR"/></logger>
<logger category="my.another.package"><level name="FINE"/></logger>
EOF
)
LOGGER_CATEGORIES=" com.my.package:ALL,my.other.package:ERROR,my.another.package"
run add_logger_category
result=$(xmllint --xpath "//*[local-name()='subsystem']//*[local-name()='logger'][@category='com.my.package' or @category='my.other.package' or @category='my.another.package']" $CONFIG_FILE)
result="$(echo "<test>${result}</test>" | sed 's|\\n||g' | xmllint --format --noblanks -)"
expected=$(echo "<test>${expected}</test>" | sed 's|\\n||g' | xmllint --format --noblanks -)
echo "Expected: ${expected}"
echo "Result: ${result}"
[ "${result}" = "${expected}" ]
}

@test "Add 2 logger categories one with invalid log level" {
#this is the return of xmllint --xpath "//*[local-name()='subsystem']//*[local-name()='logger']" $CONFIG_FILE
expected=$(cat <<EOF
Expand Down