Closed scott-alvis closed 2 years ago
@scott-alvis that line of code is preserving the behavior of actually outputting to STDOUT/STDERR.
I wonder if the tooling has actually changed since I included that because previously I remember not getting local STDOUT/STDERR until I added that in.
What version of functions are you using locally? I'll have to re-check this.
Make sure you are on version 1.0.11 of this library. A very old version of this lib did have some duplication issues.
@BrianRosamilia,
I'm using the latest version 1.0.11 of the library. Additionally, I'm on azure-functions-core-tools@3.0.3904
.
Thank you for the quick response.
You are welcome. Let me do some tests over the next few days. Will take some time since I have to install all 4 versions of the tools ðŸ˜
const methods = ['log', 'info', 'warn', 'error'];
const higherOrderLog = (name, context) => {
const logFn = (...params) => {
if(context[name]){
context[name](...params);
}
else if(context.log[name]){
//Must check context.log for some of the methods (currently warn, info, error)
context.log[name](...params);
}
};
console[name] = logFn;
};
module.exports = context => methods.forEach(m => higherOrderLog(m, context));
Any chance you can try this out locally? I'll try it out on the server Monday. Just don't want to break anything.
I did confirm this behavior for versions 3 and 4 so yeah I'm fine with fixing this behavior since going forward this will be how the function host works.
Also note to my future self: use npm cli to change function tools versions, the MSI experience isnt great.
@BrianRosamilia
I've confirmed locally that the changes above fixed the issue with duplicate log entries. I replaced everything in node_modules/azure-function-log-intercept/index.js
with the above code then ran my function and no more duplicates.
Thank you!!!
Scott Alvis
Hey @scott-alvis sorry for the delay--I will publish this fix as v1.1 tonight. Please test it out and let me know
It's out in the wild. Let me know @scott-alvis
And if anyone is having any issues, let me know and use 1.0.11
I think it will be fine but I keep a healthy amount of skepticism since a surprising # of people use this package
@BrianRosamilia - Thank you, I will take a look and let you know if find any issues.
Just curious about the reasoning behind calling
savedMethod(...params);
. This appears to causing duplicate log entries, at least when running locally.Thank you,
Scott Alvis