aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> 2023-01-30 16:14:23 -0800
committerGravatar Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> 2023-01-30 16:14:23 -0800
commit8b8bd6a405d1fd8b162c7e37f7128303573176df (patch)
tree6a6cf572807744b59d9096eaf50cd0cc6f384407
parentaa10799d8a9a69b828e36cd9d295f6d5867fb511 (diff)
downloadbun-8b8bd6a405d1fd8b162c7e37f7128303573176df.tar.gz
bun-8b8bd6a405d1fd8b162c7e37f7128303573176df.tar.zst
bun-8b8bd6a405d1fd8b162c7e37f7128303573176df.zip
remove log that appears in production
-rw-r--r--src/bun.js/webcore/encoding.zig6
-rw-r--r--src/output.zig12
2 files changed, 13 insertions, 5 deletions
diff --git a/src/bun.js/webcore/encoding.zig b/src/bun.js/webcore/encoding.zig
index d0b4bdd9a..9725073a2 100644
--- a/src/bun.js/webcore/encoding.zig
+++ b/src/bun.js/webcore/encoding.zig
@@ -882,9 +882,6 @@ pub const Encoder = struct {
},
// encode latin1 into UTF16
JSC.Node.Encoding.ucs2, JSC.Node.Encoding.utf16le => {
- Output.println("writeU8 ucs2/utf16 {any} {any}", .{ len, to_len});
- Output.flush();
-
if (to_len < 2)
return 0;
@@ -972,7 +969,7 @@ pub const Encoder = struct {
},
// string is already encoded, just need to copy the data
JSC.Node.Encoding.ucs2, JSC.Node.Encoding.utf16le => {
- if(allow_partial_write) {
+ if (allow_partial_write) {
const bytes_input_len = len * 2;
const written = @min(bytes_input_len, to_len);
const input_u8 = @ptrCast([*]const u8, input);
@@ -988,7 +985,6 @@ pub const Encoder = struct {
strings.copyU16IntoU8(to[0..written], []const u8, input_u8[0..fixed_len]);
return @intCast(i64, fixed_len);
}
-
},
JSC.Node.Encoding.hex => {
diff --git a/src/output.zig b/src/output.zig
index 66eb5bd7d..ec073baa1 100644
--- a/src/output.zig
+++ b/src/output.zig
@@ -233,6 +233,9 @@ pub fn resetTerminal() void {
}
}
+/// Write buffered stdout & stderr to the terminal.
+/// Must be called before the process exits or the buffered output will be lost.
+/// Bun automatically calls this function in Global.exit().
pub fn flush() void {
if (Environment.isNative and source_set) {
source.buffered_stream.flush() catch {};
@@ -304,6 +307,9 @@ pub fn printErrorable(comptime fmt: string, args: anytype) !void {
}
}
+/// Print to stdout
+/// This will appear in the terminal, including in production.
+/// Text automatically buffers
pub fn println(comptime fmt: string, args: anytype) void {
if (fmt.len == 0 or fmt[fmt.len - 1] != '\n') {
return print(fmt ++ "\n", args);
@@ -312,6 +318,8 @@ pub fn println(comptime fmt: string, args: anytype) void {
return print(fmt, args);
}
+/// Print to stdout, but only in debug builds.
+/// Text automatically buffers
pub inline fn debug(comptime fmt: string, args: anytype) void {
if (comptime Environment.isRelease) return;
prettyErrorln("\n<d>DEBUG:<r> " ++ fmt, args);
@@ -547,6 +555,8 @@ pub fn pretty(comptime fmt: string, args: anytype) void {
prettyWithPrinter(fmt, args, print, .stdout);
}
+/// Like Output.println, except it will automatically strip ansi color codes if
+/// the terminal doesn't support them.
pub fn prettyln(comptime fmt: string, args: anytype) void {
if (enable_ansi_colors) {
println(comptime prettyFmt(fmt, true), args);
@@ -567,6 +577,8 @@ pub fn prettyError(comptime fmt: string, args: anytype) void {
prettyWithPrinter(fmt, args, printError, .Error);
}
+/// Print to stderr with ansi color codes automatically stripped out if the
+/// terminal doesn't support them. Text is buffered
pub fn prettyErrorln(comptime fmt: string, args: anytype) void {
if (fmt.len == 0 or fmt[fmt.len - 1] != '\n') {
return prettyWithPrinter(