Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(azure-functions): redirect console to azure context for logging #542

Closed
wants to merge 93 commits into from
Closed
Changes from 1 commit
Commits
Show all changes
93 commits
Select commit Hold shift + click to select a range
a1c7bbb
add a logging interceptor for azure context
mcremer-able Oct 4, 2022
e28b891
Don't intercept ,if we are already intercepting
mcremer-able Oct 13, 2022
660acd1
docs: fix readme grammar (#813)
alvarlagerlof Jan 9, 2023
a1b2db9
docs: fix deprecated function in routing example (#816)
pschnyder Jan 9, 2023
d1b0cfb
docs: add new render deployment example & steps (#811)
connectshark Jan 9, 2023
a3492b0
fix(build): do not override publicAssets (#817)
antfu Jan 9, 2023
3f8ca7a
feat(dev): support for `/_vfs.json` (#809)
antfu Jan 9, 2023
d256487
chore(deps): update devdependency @types/fs-extra to v11 (#814)
renovate[bot] Jan 9, 2023
45b3abd
chore(deps): update all non-major dependencies (#810)
renovate[bot] Jan 9, 2023
dcc59c7
fix(dev): improve vfs ui (#802)
antfu Jan 9, 2023
976d81d
chore(deps): update dependency mlly to ^1.1.0 (#820)
renovate[bot] Jan 10, 2023
4654e59
fix: resolve and include scanDirs within `node_modules` for auto impo…
yassilah Jan 10, 2023
15edef0
style: lint code
pi0 Jan 10, 2023
e12dae1
chore(deps): update all non-major dependencies (#824)
renovate[bot] Jan 11, 2023
5d5b62e
refactor: update `event.` to `event.node.` (#828)
cpreston321 Jan 11, 2023
bece791
fix(netlify, vercel): explicit server rendering with disabled cache/s…
danielroe Jan 11, 2023
84a65bc
docs: fix typo in code block (#830)
nexxeln Jan 11, 2023
ae708f0
chore(deps): update all non-major dependencies to ^0.27.1 (#831)
renovate[bot] Jan 11, 2023
8194ee4
chore(deps): update all non-major dependencies (#832)
renovate[bot] Jan 12, 2023
c1df65e
feat(netlify): use esm entrypoint (#833)
danielroe Jan 13, 2023
0211e60
chore: add lint fix command shortcut (#835)
danielroe Jan 13, 2023
6585e8d
fix(prerender): check link's pathname only for extensions (#791)
dargmuesli Jan 13, 2023
ed3a480
fix(rumtime): disable server-timing header via options.timing (#823)
clarkdo Jan 13, 2023
7517293
fix: avoid using file urls for normalized paths in options
pi0 Jan 13, 2023
2e43d30
ci: run tests against windows as well (#837)
danielroe Jan 13, 2023
bb9ac5b
chore: update lockfile
pi0 Jan 13, 2023
2ce4edb
fix: rollup treeshake is dump
pi0 Jan 13, 2023
0638f64
fix(externals): normalize `inline` and `external` windows paths
pi0 Jan 13, 2023
d23bc2d
chore(deps): update all non-major dependencies (#839)
renovate[bot] Jan 14, 2023
f812c81
chore(deps): update devdependency eslint to ^8.32.0 (#842)
renovate[bot] Jan 15, 2023
e7b250f
feat!: rewrite external copy with multi version hoisting support (#782)
pi0 Jan 16, 2023
5e484c3
fix(netlify, aws): omit cookies from v1 response (#834)
danielroe Jan 16, 2023
ca35421
fix: filter unique scanned handlers (#807)
yassilah Jan 16, 2023
b773ebe
docs: add cache base option example & description (#781)
LouisHaftmann Jan 16, 2023
b91db6f
feat: add `shouldInvalidateCache ` option to cache utils (#746)
yassilah Jan 16, 2023
d89fa5f
fix(nitro): resolve server asset dirs relative to `srcDir` (#825)
cpreston321 Jan 16, 2023
cf26c84
chore(deps): update all non-major dependencies (#847)
renovate[bot] Jan 17, 2023
bce44da
chore(deps): update all non-major dependencies (#848)
renovate[bot] Jan 17, 2023
686a560
fix(public-assets): mock readAsset promise properly (#851)
harlan-zw Jan 19, 2023
3d61ebf
feat: `edgio` preset (replacing `layer0`) (#858)
pi0 Jan 20, 2023
71576c0
feat: support `maxAge` for public assets (#860)
pi0 Jan 20, 2023
a52c832
test: update fixtures
pi0 Jan 20, 2023
456f82a
feat: support `staleMaxAge: -1` to always respond stale value (#857)
yassilah Jan 20, 2023
b77735e
fix(externals): avoid recursive package links
pi0 Jan 20, 2023
63e250d
chore(release): v2.0.0-rc.0
pi0 Jan 20, 2023
dc4e2f1
fix(prerender): update preview command to serve matching routes (#864)
danielroe Jan 23, 2023
02556e6
chore: lint with `eslint --cache` and improve types in `.eslintrc` (#…
o-az Jan 23, 2023
6b65508
fix(externals): support orphan files in `node_modules` (#865)
pi0 Jan 23, 2023
a5586f8
fix: avoid hiding original rollup error message
pi0 Jan 23, 2023
d0ab926
feat(externals): apply `production` condition to package.exports (#867)
pi0 Jan 23, 2023
724c709
feat: enable auto imports from `utils` dir (#866)
pi0 Jan 23, 2023
f5c387f
fix(cache): only update cache in storage once per pending request (#861)
yassilah Jan 23, 2023
c52d256
chore: update dependencies
pi0 Jan 23, 2023
246b726
chore: remove random import
pi0 Jan 23, 2023
5830bf3
chore(release): v2.0.0-rc.1
pi0 Jan 23, 2023
113d31e
fix: add node16 compatible type declaration (#868)
danielroe Jan 24, 2023
d73998e
fix(externals): improve multi version handling (#871)
pi0 Jan 24, 2023
5f142cc
chore(release): v2.0.0
pi0 Jan 24, 2023
f5a5a8e
feat: add `shouldBypassCache` option to cache utils (#874)
MiniDigger Jan 25, 2023
61f0c7b
docs(deployment): heroku with nginx (#873)
adetayoadeyemi Jan 25, 2023
872a301
docs(netlify): clarify placement of `_redirects` file (#870)
OlaAlsaker Jan 25, 2023
cd53d39
chore(deps): update dependency unimport to v2 (#869)
renovate[bot] Jan 25, 2023
4193603
docs(digitalocean): update deployment guide (#862)
christopher4lis Jan 25, 2023
2c52c62
feat(cache): allow async `getKey` option (#878)
MiniDigger Jan 25, 2023
153f286
fix(scan): do not dedup middleware handlers (#880)
danielroe Jan 25, 2023
6596c5f
fix(externals): use portable symlinks (#882)
pi0 Jan 25, 2023
963c587
chore: update dependencies
pi0 Jan 25, 2023
266e2ef
chore(release): v2.1.0
pi0 Jan 25, 2023
917c7e6
chore(deps): update pnpm to v7.26.0 (#884)
renovate[bot] Jan 26, 2023
53d37db
chore(deps): update all non-major dependencies (#890)
renovate[bot] Jan 30, 2023
762ee47
fix: resolve server assets dir relative to `srcDir` (#893)
danielroe Jan 30, 2023
930438a
fix(prerender): encode urls passed to local fetch (#891)
manh-gntvn Jan 30, 2023
b77f082
chore: update unenv
pi0 Jan 30, 2023
50e1a8f
chore: format code
pi0 Jan 30, 2023
af0409f
chore(release): v2.1.1
pi0 Jan 30, 2023
a12e1e7
fix(types): allow narrowing of the method option in `NitroFetchOption…
dsluijk Jan 31, 2023
40c21a2
chore(deps): update devdependency typescript to ^4.9.5 (#895)
renovate[bot] Feb 1, 2023
c784b87
fix(vercel-edge): add temporary workaround for ‍`process.cwd‍` usage …
harlan-zw Feb 1, 2023
f7eed65
fix(dev): don't overwrite proxy headers if already set (#896)
MikeBellika Feb 1, 2023
881a0ba
fix: provide fallback string values for undefined `runtimeConfig` (#907)
danielroe Feb 4, 2023
325e919
docs: fix heroku typo (#900)
clew-bot Feb 4, 2023
10a7ee7
docs: fix stormkit images path (#903)
ralacerda Feb 4, 2023
4d89e31
fix(vercel): allow non-glob cache rules to apply to `/` (#908)
danielroe Feb 4, 2023
dbb89a1
chore: update dependencies
pi0 Feb 4, 2023
78dd4f9
fix(externals): use stable dependency tree (#909)
pi0 Feb 5, 2023
a899f1d
docs: fix path for server assets (#917)
serkodev Feb 6, 2023
a459e1e
fix(dev): mount `src` and `root` as read-only by default (#920)
pi0 Feb 6, 2023
41884ba
chore(deps): update all non-major dependencies (#911)
renovate[bot] Feb 6, 2023
c45e4c9
spread params
mcremer-able Feb 6, 2023
e1e0114
add a logging interceptor for azure context
mcremer-able Oct 4, 2022
1068b4e
Don't intercept ,if we are already intercepting
mcremer-able Oct 13, 2022
f5c9b36
spread params
mcremer-able Feb 6, 2023
c277c76
Merge branch 'main' of https://github.com/mcremer-able/nitro
mcremer-able Feb 6, 2023
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
21 changes: 20 additions & 1 deletion src/runtime/entries/azure-functions.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,28 @@
import '#internal/nitro/virtual/polyfill'
import { nitroApp } from '../app'

const levels = ['log', 'info', 'warn', 'error']

const higherOrderLog = (name: string, context) => {
const logFn = (params) => {
if (context[name]) {
context[name](...params)
} else if (context.log[name]) {
context.log[name](...params)
}
}

console[name] = logFn
}
/**
* intercepts all calls to console.* and redirects them to the azure context logger
*/
const interceptLogging = context =>
levels.forEach(m => higherOrderLog(m, context))

export async function handle (context, req) {
const url = '/' + (req.params.url || '')

interceptLogging(context)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will this have issues with logs being associated to the wrong request if there are multiple parallel requests?

If not (that is, if there is only one aggregated logging bucket), then do we need to run this on every incoming request or could we early return if the interceptor has already been run?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As I understand it, it is a single logging bucket for the whole function app.

We could optimize and dont intercept ,if we are already intercepting.
The gains do not outweight the potentiell bugs, in my opinion, with the added complexity we get.

I rather intercept twice than miss a critical log.

const { body, status, statusText, headers } = await nitroApp.localCall({
url,
headers: req.headers,
Expand Down