Add CoreLoggerInstance

This commit is contained in:
JeremyStar™ 2024-03-17 22:32:14 +01:00
parent db8a0b5f0c
commit a533c8916f
8 changed files with 49 additions and 5 deletions

View file

@ -1,5 +1,5 @@
---
sidebar_position: 5
sidebar_position: 6
---
# `CoreConfiguration`

View file

@ -1,5 +1,5 @@
---
sidebar_position: 4
sidebar_position: 5
---
# `CoreTypes`

View file

@ -14,6 +14,8 @@ Emitted on any log call, permitted or not. \
**format** is set to `""` when **allowed** is set `false`.
## Functions
### *CoreLoggerInstance* <u>get_instance</u>(*String* <u>origin</u>)
Returns a [logger instance](/reference/loggerinstance), which are two fancy words meaning you don't need to pass <u>origin</u> every time you want to log something.
### *bool* <u>is_level_allowed</u>(*CoreTypes.LoggerLevel* <u>level</u>)
Checks if the specified log level is permitted by the current configuration.
### *void* <u>diag</u>(*String* <u>origin</u>, *String* <u>message</u>)
@ -33,4 +35,4 @@ Using the `await` keyword is required for this function.
:::danger
Please do not set `framework_crash` to `true`. Thank you.
:::
Handles crashes. Will terminate your game/application immediately.
Handles crashes. Will terminate your game/application immediately.

View file

@ -0,0 +1,23 @@
---
sidebar_position: 3
---
# `LoggerInstance`
Passes <u>origin</u> for you.
## Functions
### *void* <u>diag</u>(*String* <u>message</u>)
Prints a diagnostic message
### *void* <u>verb</u>(*String* <u>message</u>)
Prints a verbose message
### *void* <u>info</u>(*String* <u>message</u>)
Prints an informational message
### *void* <u>warn</u>(*String* <u>message</u>)
Prints a warning message
### *void* <u>error</u>(*String* <u>message</u>)
Prints an error message
### *void* <u>crash</u>(*String* <u>message</u>)
:::note[Awaiting required]
Using the `await` keyword is required for this function.
:::
Handles crashes. Will terminate your game/application immediately.

View file

@ -1,5 +1,5 @@
---
sidebar_position: 3
sidebar_position: 4
---
# `Miscellaneous`

View file

@ -1,5 +1,5 @@
---
sidebar_position: 6
sidebar_position: 7
---
# `Scene Management System`

View file

@ -0,0 +1,16 @@
extends Node
class_name CoreLoggerInstance
var logger: CoreBaseModule
var origin: String
func _init(logger_new: CoreBaseModule, origin_new: String) -> void:
logger = logger_new
origin = origin_new
func diag(message: String) -> void: logger.diag(origin, message)
func verb(message: String) -> void: logger.verb(origin, message)
func info(message: String) -> void: logger.info(origin, message)
func warn(message: String) -> void: logger.warn(origin, message)
func error(message: String) -> void: logger.error(origin, message)
func crash(message: String) -> void: await logger.crash(origin, message)

View file

@ -193,3 +193,6 @@ func infof(origin: String, message: String) -> void: _log(CoreTypes.LoggerLevel.
func warnf(origin: String, message: String) -> void: _log(CoreTypes.LoggerLevel.WARN, core.basepath.replace("res://", "") + "src/" + origin, message)
func errorf(origin: String, message: String) -> void: _log(CoreTypes.LoggerLevel.ERROR, core.basepath.replace("res://", "") + "src/" + origin, message)
func crashf(origin: String, message: String) -> void: crash(core.basepath.replace("res://", "") + "src/" + origin, message)
# Returns a logger instance
func get_instance(origin: String) -> CoreLoggerInstance: return CoreLoggerInstance.new(logger, origin)