GH-456 Fix Azure logging

Added static delegate context which holds target context and is also refreshed with new context on each request

Resolves #456
This commit is contained in:
Oleg Zhurakousky
2020-04-02 16:36:54 +02:00
parent d3345576bd
commit aa721a7b43
6 changed files with 59 additions and 75 deletions

View File

@@ -22,6 +22,8 @@ import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import com.microsoft.azure.functions.ExecutionContext;
@SpringBootApplication
public class Config {
@@ -30,58 +32,12 @@ public class Config {
}
@Bean
public Function<Foo, Bar> uppercase() {
return foo -> new Bar(foo.getValue().toUpperCase());
public Function<String, String> uppercase(ExecutionContext context) {
return value -> {
context.getLogger().info("Uppercasing " + value);
return value.toUpperCase();
};
}
}
class Foo {
private String value;
Foo() {
}
Foo(String value) {
this.value = value;
}
public String lowercase() {
return this.value.toLowerCase();
}
public String uppercase() {
return this.value.toUpperCase();
}
public String getValue() {
return this.value;
}
public void setValue(String value) {
this.value = value;
}
}
class Bar {
private String value;
Bar() {
}
Bar(String value) {
this.value = value;
}
public String getValue() {
return this.value;
}
public void setValue(String value) {
this.value = value;
}
}