Update CoreLoggerInstance

This commit is contained in:
JeremyStar™ 2024-03-18 03:03:54 +01:00
parent bb18dfc174
commit d0e8e394fa
2 changed files with 32 additions and 5 deletions

View file

@ -1,16 +1,43 @@
extends Node # CORE FRAMEWORK SOURCE FILE
# Copyright (c) 2024 The StarOpenSource Project & Contributors
# Licensed under the GNU Affero General Public License v3
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
## Passes [code]origin[/code] for you.
##
## Pretty much a wrapper around CORE's logging implementation.
## CoreLoggerInstance's only job is to save you some effort aka.
## you not needing to pass the [code]origin[/code] argument to each
## and every log call, which is extremely annoying. Thank us later ;)
extends CoreBaseModule
class_name CoreLoggerInstance class_name CoreLoggerInstance
var logger: CoreBaseModule ## Class name
var origin: String var origin: String
func _init(logger_new: CoreBaseModule, origin_new: String) -> void: func _init(origin_new: String) -> void:
logger = logger_new
origin = origin_new origin = origin_new
## Prints a diagnostic message
func diag(message: String) -> void: logger.diag(origin, message) func diag(message: String) -> void: logger.diag(origin, message)
## Prints a verbose message
func verb(message: String) -> void: logger.verb(origin, message) func verb(message: String) -> void: logger.verb(origin, message)
## Prints a informational message
func info(message: String) -> void: logger.info(origin, message) func info(message: String) -> void: logger.info(origin, message)
## Prints a warning message
func warn(message: String) -> void: logger.warn(origin, message) func warn(message: String) -> void: logger.warn(origin, message)
## Prints a error message
func error(message: String) -> void: logger.error(origin, message) func error(message: String) -> void: logger.error(origin, message)
## Handles crashes. Will terminate your game/application immediately.
func crash(message: String) -> void: await logger.crash(origin, message) func crash(message: String) -> void: await logger.crash(origin, message)

View file

@ -195,4 +195,4 @@ func errorf(origin: String, message: String) -> void: _log(CoreTypes.LoggerLevel
func crashf(origin: String, message: String) -> void: crash(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 # Returns a logger instance
func get_instance(origin: String) -> CoreLoggerInstance: return CoreLoggerInstance.new(self, origin) func get_instance(origin: String) -> CoreLoggerInstance: return CoreLoggerInstance.new(origin)