Skip to content

Commit

Permalink
Update log to 0.4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Vorlias committed Jul 13, 2021
1 parent da9809b commit b67cfb0
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 15 deletions.
24 changes: 22 additions & 2 deletions example/server/index.server.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import Log, { Logger } from "@rbxts/log";
import { Workspace } from "@rbxts/services";
import Zircon, { ZirconServer } from "@zircon";
import ZirconPrint from "BuiltIn/Print";
import { ZirconFunctionBuilder } from "Class/ZirconFunctionBuilder";
Expand Down Expand Up @@ -53,11 +54,30 @@ ZirconServer.Registry.RegisterFunction(
[ZirconServer.Registry.User],
);

delayAsync(5).then(() => {
Log.Verbose("A verbose message. Yes?");
class Example {
private _logger = Log.ForContext(Example);
public constructor() {}
public example() {
this._logger.Info("Testing from class!");
this._logger.Warn("Warning from class!");
}
}

Promise.delay(5).then(() => {
const testLogger = Log.ForScript();

testLogger.Verbose("A verbose message. Yes?");
testLogger.Info("Breaking <0> RichText Fix");
testLogger.Info("Another test <font>Test</font>");

new Example().example();

Log.ForContext(Workspace).Info("Using workspace");

Log.Debug("A debug message, yes");
Log.Info("Hello, {Test}! {Boolean} {Number} {Array}", "Test string", true, 10, [1, 2, 3, [4]]);
Log.Warn("Warining {Lol}", "LOL!");

Log.Error("ERROR LOL {Yes}", true);
Log.Fatal("Fatal message here");
});
Expand Down
14 changes: 7 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"name": "@rbxts/zircon",
"version": "0.8.1-beta.0",
"version": "0.9.0-beta.0",
"description": "",
"main": "out/init.lua",
"scripts": {
"prepare": "npm run build",
"build": "rbxtsc",
"build": "rbxtsc --verbose",
"dev:example": "concurrently npm:watch:example npm:serve:example",
"build:example": "rbxtsc --type=game -p ./example -i ./include",
"build:luau": "rbxtsc --verbose --type=model --rojo=\"luau/build.project.json\"",
Expand Down Expand Up @@ -39,7 +39,7 @@
},
"dependencies": {
"@rbxts/flipper": "^2.0.0",
"@rbxts/log": "^0.3.0-alpha.1",
"@rbxts/log": "^0.4.0-alpha.0",
"@rbxts/maid": "^1.0.0-ts.1",
"@rbxts/message-templates": "^0.2.0",
"@rbxts/net": "^2.1.3",
Expand Down
15 changes: 12 additions & 3 deletions src/Client/Components/OutputMessage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,13 @@ import { LogLevel } from "@rbxts/log";
import { MessageTemplateParser } from "@rbxts/message-templates";
import { ZirconStructuredMessageTemplateRenderer } from "Client/Format/ZirconStructuredMessageTemplate";

function sanitise(input: string) {
return input.gsub("[<>]", {
">": "&gt;",
"<": "&lt;",
})[0];
}

interface OutputMessageProps {
Message: ZrOutputMessage | ZirconLogMessage | ZrOutputMessage | ZirconStructuredLogMessage;
ShowTags?: boolean;
Expand Down Expand Up @@ -56,7 +63,7 @@ function OutputMessage(props: OutputMessageProps) {
data,
} = output;

const tokens = MessageTemplateParser.GetTokens(Template);
const tokens = MessageTemplateParser.GetTokens(sanitise(Template));
const renderer = new ZirconStructuredMessageTemplateRenderer(tokens, theme);
const text = renderer.Render(output.data);

Expand Down Expand Up @@ -94,8 +101,10 @@ function OutputMessage(props: OutputMessageProps) {
}

if (props.ShowTags) {
if (data.Tag) {
messages.push("- " + italicize(getRichTextColor3(theme, "Grey", tostring(data.Tag))));
if (data.SourceContext) {
messages.push(
"- " + italicize(getRichTextColor3(theme, "Grey", tostring(data.SourceContext))),
);
}
}
} else if (output.type === ZirconMessageType.ZirconLogOutputMesage) {
Expand Down

0 comments on commit b67cfb0

Please sign in to comment.