Skip to content

Commit

Permalink
Merge pull request #163 from supabase/stdout
Browse files Browse the repository at this point in the history
Deno.stdout integration
  • Loading branch information
laktek authored Aug 23, 2023
2 parents 5d24998 + 4ad1d81 commit fb4e900
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
10 changes: 9 additions & 1 deletion crates/sb_core/js/denoOverrides.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import {
import { serveHttp } from "ext:sb_core_main_js/js/http.js";
import * as fs from "ext:deno_fs/30_fs.js";
import { osCalls } from "ext:sb_os/os.js"
import * as io from "ext:deno_io/12_io.js";


const osCallsVars = {
gid: osCalls.gid,
Expand Down Expand Up @@ -88,6 +90,10 @@ const fsVars = {
utimeSync: fs.utimeSync,
}

const ioVars = {
stdout: io.stdout,
}

const denoOverrides = {
listen: net.listen,
connect: net.connect,
Expand All @@ -101,8 +107,10 @@ const denoOverrides = {
errors: errors,
refTimer: timers.refTimer,
unrefTimer: timers.unrefTimer,
isatty: (arg) => false,
...ioVars,
...fsVars,
...osCallsVars
}

export { denoOverrides, fsVars, osCallsVars };
export { denoOverrides, fsVars, osCallsVars, ioVars };
13 changes: 13 additions & 0 deletions examples/logger-stdout/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import Logger from "https://deno.land/x/[email protected]/logger.ts";
import { serve } from "https://deno.land/[email protected]/http/server.ts"

const logger = new Logger();

serve(async (req: Request) => {
logger.info("hello from logger");

return new Response(
JSON.stringify({ hello: "world" }),
{ status: 200, headers: { "Content-Type": "application/json" } },
)
})

0 comments on commit fb4e900

Please sign in to comment.