Skip to content
프로젝트

소개

Logging singleton for Godot Engine projects (GDScript plugin)

기타 프로젝트

이 수치를 측정하는 방법

측정된 스타 증가

in 24h
0
in 7 days
0
in 15 days
0
in 1 month
기록 수집 중

서로 겹치는 기간의 순증가량이며 일별 합계가 아닙니다. 측정값이 없으면 비워 둡니다. 스타는 관심도를 나타내며 품질을 보장하지 않습니다.

README.md

Original

Godot Logger - Logging Addon for Godot Engine

The Godot Logger is a plugin that provides a logging API for projects developed with Godot Engine.

Usage

  1. Clone or extract this repository as the res://addons/godot-logger folder in your project.
  2. Enable the addon from Project -> Project Settings -> Plugins -> Godot Logger.
  3. An autoloaded script will be added to your project singletons list as KLogger.

The methods of the API can then be accessed from any other script via the KLogger singleton:

  KLogger.warn("Alpaca mismatch!")

  KLogger.add_module("mymodule")
  KLogger.info("Reticulating splines...", "mymodule")

Read the code for details about the API, it's extensively documented.

Output format configuration

The output_format property can be customized using format fields from the FORMAT_IDS dictionary. They are placeholders which will be replaced by the relevant content.

Log format fields:

  • {LVL} = Level of the log
  • {MOD} = Module that does the logging
  • {MSG} = Message from the user
  • {TIME} = Timestamp when the logging occurred
  • {ERR_MSG} = Error message corresponding to the error code, if provided. It is automatically prepended with a space.

The timestamp format can be configured for each module using the time_format property, with the placeholders described below.

Timestamp fields:

  • YYYY = Year
  • MM = Month
  • DD = Day
  • hh = Hour
  • mm = Minute
  • ss = Second
  • SSS = Millisecond

Error codes:

All logging levels can also optionally include an Error code, which will be mapped to a human-readable error message.

Example:

KLogger.error("Failed to rotate the albatross", "main", ERR_INVALID_DATA)

Example

var msg = "Error occurred!"

KLogger.output_format = "[{TIME}] [{LVL}] [{MOD}] {MSG}"
KLogger.time_format = "YYYY.MM.DD hh:mm:ss.SSS"
KLogger.error(msg)

KLogger.time_format = "hh:mm:ss"
KLogger.error(msg)

KLogger.output_format = "[{LVL}] {MSG} at {TIME}"
KLogger.error(msg)

Results in:

[2020.10.09 12:10:47.034] [ERROR] [main] Error occurred!

[12:10:47] [ERROR] [main] Error occurred!

[ERROR] Error occurred! at 12:10:47

Licensing

The KLogger class and all other files of this repository are distributed under the MIT license (see the LICENSE.md file).

관련 프로젝트 살펴보기

불러오는 중…