Last active
December 30, 2023 08:06
-
-
Save gaymeowing/7dcf8f5b7a7ccf4121bcae3bc47d6aa5 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--!strict | |
-- ConsoleFormatter | |
-- A utility module for easily formatting outputs for print, warn and errors! | |
-- @Kalrnlo | |
-- 30/12/2023 | |
export type OutputType = "Critical" | "Warning" | "Error" | "Log" | "Debug" | "1" | "2" | "3" | "4" | "5" | |
local DefualtFormat = "[%s][%s] :: " | |
local OutputTypes = { | |
[1] = "Debug", | |
[2] = "Log", | |
[3] = "Warning", | |
[4] = "Error", | |
[5] = "Critical" | |
} | |
return function(Script: BaseScript | string, Format: string?) | |
local ScriptName = if typeof(Script) == "Instance" then Script.Name else Script | |
local Format = Format or DefualtFormat | |
return function(OutputType: OutputType | number, ...: any) | |
local OutputType = if tonumber(OutputType) then OutputTypes[OutputType :: number] else OutputType | |
return string.format(Format, ScriptName, OutputType), ... | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--!strict | |
local ConsoleFormatter = require("ConsoleFormatter") | |
local Format = ConsoleFormatter(script) | |
print(Format "Log", "Hello World!") -- [script][Log] :: Hello World | |
ͺ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment