CORE/src/classes/loggerinstance.gd

56 lines
2.4 KiB
GDScript

# 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 Node
class_name CoreLoggerInstance
## Reference to CORE's logger module.
var logger: CoreBaseModule
## The origin argument.
var origin: String
## Indicates that the parent class is part of the CORE Framework.
## [b]Note: [i]Don't modify.[/i][/b]
var framework: bool = false
## Is set to the parent owning the logger instance.
## [b]Note: [i]Don't modify.[/i][/b]
var parent: Object
## The instance constructor.
func _init(logger_new: CoreBaseModule, origin_new: String, parent_new: Object) -> void:
logger = logger_new
origin = origin_new
parent = parent_new
## Prints a diagnostic message.
func diag(message: String) -> void: logger.diag(origin, message)
## Prints a verbose message.
func verb(message: String) -> void: logger.verb(origin, message)
## Prints an informational message.
func info(message: String) -> void: logger.info(origin, message)
## Prints a warning message.
func warn(message: String) -> void: logger.warn(origin, message)
## Prints an error message.
func error(message: String) -> void: logger.error(origin, message)
## Handles crashes. Will terminate your game/application immediately.[br]
## [b]Note: [i]Using the [code]await[/code] keyword is required for this function.[/i][/b]
func crash(message: String) -> void: await logger.crash(origin, message, framework)