changed projects structure
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
class ConsoleApi {
|
||||
constructor(mem) {
|
||||
this.mem = mem;
|
||||
}
|
||||
|
||||
trace = (str_ptr, str_len) => {
|
||||
console.trace(this.mem.loadString(str_ptr, str_len));
|
||||
};
|
||||
|
||||
debug = (str_ptr, str_len) => {
|
||||
console.debug(this.mem.loadString(str_ptr, str_len));
|
||||
};
|
||||
info = (str_ptr, str_len) => {
|
||||
console.info(this.mem.loadString(str_ptr, str_len));
|
||||
};
|
||||
|
||||
warn = function(str_ptr, str_len) {
|
||||
console.warn(this.mem.loadString(str_ptr, str_len));
|
||||
};
|
||||
|
||||
error = (str_ptr, str_len) => {
|
||||
console.error(this.mem.loadString(str_ptr, str_len));
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
package js_console
|
||||
|
||||
foreign import "console_api"
|
||||
|
||||
@(default_calling_convention="contextless")
|
||||
foreign console_api {
|
||||
// you can pass values to the JS side too.
|
||||
trace :: proc(str: string) ---
|
||||
debug :: proc(str: string) ---
|
||||
info :: proc(str: string) ---
|
||||
warn :: proc(str: string) ---
|
||||
error :: proc(str: string) ---
|
||||
}
|
||||
@@ -1,23 +1,12 @@
|
||||
package js_log
|
||||
package js_console
|
||||
|
||||
import "core:log"
|
||||
import "core:mem"
|
||||
|
||||
foreign import "js_log"
|
||||
|
||||
@(default_calling_convention="contextless")
|
||||
foreign js_log {
|
||||
// you can pass values to the JS side too.
|
||||
trace :: proc(str: string) ---
|
||||
debug :: proc(str: string) ---
|
||||
info :: proc(str: string) ---
|
||||
warn :: proc(str: string) ---
|
||||
error :: proc(str: string) ---
|
||||
}
|
||||
|
||||
// Beware that .FATAL is logged as .Error as it is not supported by this interface
|
||||
// Unknown log levels will be logged by calling 'console.trace'
|
||||
js_console_logger_proc :: proc(data: rawptr, level: log.Level, text: string, options: log.Options, location := #caller_location) {
|
||||
// right now options are ignored, maybe revisit it later
|
||||
|
||||
switch level {
|
||||
case .Debug: debug(text)
|
||||
case .Info: info(text)
|
||||
@@ -28,11 +17,11 @@ js_console_logger_proc :: proc(data: rawptr, level: log.Level, text: string, opt
|
||||
}
|
||||
}
|
||||
|
||||
create_js_console_logger :: proc(options := log.Default_Console_Logger_Opts) -> log.Logger {
|
||||
create_js_console_logger :: proc() -> log.Logger {
|
||||
return log.Logger{
|
||||
lowest_level = .Debug,
|
||||
procedure = js_console_logger_proc,
|
||||
options = options,
|
||||
options = {},
|
||||
data = nil
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user