mirror of
https://github.com/oven-sh/bun
synced 2026-02-14 12:51:54 +00:00
refactor(postgres) improve postgres code base (#20808)
Co-authored-by: cirospaciari <6379399+cirospaciari@users.noreply.github.com>
This commit is contained in:
25
src/sql/postgres/DebugSocketMonitorReader.zig
Normal file
25
src/sql/postgres/DebugSocketMonitorReader.zig
Normal file
@@ -0,0 +1,25 @@
|
||||
var file: std.fs.File = undefined;
|
||||
pub var enabled = false;
|
||||
pub var check = std.once(load);
|
||||
|
||||
pub fn load() void {
|
||||
if (bun.getenvZAnyCase("BUN_POSTGRES_SOCKET_MONITOR_READER")) |monitor| {
|
||||
enabled = true;
|
||||
file = std.fs.cwd().createFile(monitor, .{ .truncate = true }) catch {
|
||||
enabled = false;
|
||||
return;
|
||||
};
|
||||
debug("duplicating reads to {s}", .{monitor});
|
||||
}
|
||||
}
|
||||
|
||||
pub fn write(data: []const u8) void {
|
||||
file.writeAll(data) catch {};
|
||||
}
|
||||
|
||||
const debug = bun.Output.scoped(.Postgres, false);
|
||||
|
||||
// @sortImports
|
||||
|
||||
const bun = @import("bun");
|
||||
const std = @import("std");
|
||||
Reference in New Issue
Block a user