changed projects structure
This commit is contained in:
@@ -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) ---
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package js_console
|
||||
|
||||
import "core:log"
|
||||
|
||||
// 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)
|
||||
case .Warning: warn(text)
|
||||
case .Error: error(text)
|
||||
case .Fatal: error(text)
|
||||
case: trace(text)
|
||||
}
|
||||
}
|
||||
|
||||
create_js_console_logger :: proc() -> log.Logger {
|
||||
return log.Logger{
|
||||
lowest_level = .Debug,
|
||||
procedure = js_console_logger_proc,
|
||||
options = {},
|
||||
data = nil
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user