Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F4497638
debug.zig
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
866 B
Referenced Files
None
Subscribers
None
debug.zig
View Options
const
std
=
@import
(
"std"
);
const
builtin
=
@import
(
"builtin"
);
pub
var
enabled
:
bool
=
false
;
pub
fn
log
(
comptime
fmt
:
[]
const
u8
,
args
:
anytype
)
void
{
if
(
!
enabled
)
return
;
var
buf
:
[
2048
]
u8
=
undefined
;
const
msg
=
std
.
fmt
.
bufPrint
(
&
buf
,
"[pkg] "
++
fmt
++
"
\n
"
,
args
)
catch
return
;
if
(
comptime
builtin
.
os
.
tag
==
.
windows
)
{
const
handle
=
std
.
os
.
windows
.
GetStdHandle
(
std
.
os
.
windows
.
STD_ERROR_HANDLE
)
catch
return
;
_
=
std
.
os
.
windows
.
WriteFile
(
handle
,
msg
,
null
)
catch
{};
}
else
_
=
std
.
c
.
write
(
2
,
msg
.
ptr
,
msg
.
len
);
}
pub
fn
timer
(
comptime
label
:
[]
const
u8
,
start
:
u64
)
u64
{
if
(
!
enabled
)
return
start
;
const
now
=
std
.
time
.
nanoTimestamp
();
const
elapsed_ns
:
u64
=
@intCast
(
now
-
@as
(
i128
,
start
));
const
elapsed_ms
=
elapsed_ns
/
1
_000_000
;
log
(
"{s}: {d}ms"
,
.{
label
,
elapsed_ms
});
return
@intCast
(
now
);
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, May 3, 7:20 AM (21 m, 37 s)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
533570
Default Alt Text
debug.zig (866 B)
Attached To
Mode
rANT Ant
Attached
Detach File
Event Timeline
Log In to Comment