Azure / azure-functions-host

The host/runtime that powers Azure Functions
https://functions.azure.com
MIT License
1.91k stars 436 forks source link

Expose function level TraceWriter to Binding Extensions #820

Open pragnagopa opened 7 years ago

pragnagopa commented 7 years ago

TraceWriter in ScriptBindingProvider and ExtensionConfigContext are host level trace writers. We need a TraceWriter that can log at function level

Repro steps

Provide the steps required to reproduce the problem

EnableTestSend on NH output binding:

{ "type": "notificationHub", "name": "notification", "hubName": "scripthub", "connection": "scripthub_NOTIFICATIONHUB", "direction": "out", "enableTestSend": true, "platform": "wns" }

Expected behavior

NH debug logs show up in logs window

Actual behavior

NH debug logs show up in LogStream

Known workarounds

N/A

Related information

Provide any related information

mathewc commented 7 years ago

Do you mean that the actual behavior is that the logs only show in host logs, not function logs?

It might be the case that this is only an issue for extensions written on the "new model". E.g. your BuildFromAttribute func that creates your async collector doesn't have access to the actual invocation binding context that contains the per invocation file logger that we set up.

pragnagopa commented 7 years ago

Yes. Correct. Logs only show up in host logs and not in function logs as Async collector does not have access to tracewriter for the invoker.

jansoren commented 6 years ago

Is it possible to extend the ExtensionConfigContext.Trace to also log at function level? This would be super since we are using dependency injection in implementation of IExtensionConfigProvider to setup our logger. See code here