mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-24 00:23:12 +09:00
Add formatting of Script and Verbose levels
Detect and colour the Script and Verbose levels. The format of the source file for the Script level is slightly different and needs an update to the output parsing.
This commit is contained in:
1 parent
c8c65d2e92
commit
db1f239a0f
5 files changed
+69
-4
No files matched your search
+5
-1
@@ -43,7 +43,11 @@ function formatOutputColored(output) {
|
|||||||
let info = "";
|
let info = "";
|
||||||
if (output.type === "log") {
|
if (output.type === "log") {
|
||||||
let level = output.level;
|
let level = output.level;
|
||||||
if (level === "Info") {
|
if (level === "Script") {
|
||||||
|
level = chalk.bold.greenBright(level);
|
||||||
|
} else if (level === "Verbose") {
|
||||||
|
level = chalk.bold.gray(level);
|
||||||
|
} else if (level === "Info") {
|
||||||
level = chalk.bold.blueBright(level);
|
level = chalk.bold.blueBright(level);
|
||||||
} else if (output.level === "Warning") {
|
} else if (output.level === "Warning") {
|
||||||
level = chalk.bold.yellowBright(level);
|
level = chalk.bold.yellowBright(level);
|
||||||
|
|||||||
@@ -318,13 +318,15 @@ function parseOutput(line, source) {
|
|||||||
// A seconds output has two different kinds of formats: The first is a
|
// A seconds output has two different kinds of formats: The first is a
|
||||||
// log level and source location and has a format of
|
// log level and source location and has a format of
|
||||||
// "Level File.cpp:123: message"
|
// "Level File.cpp:123: message"
|
||||||
const secLogRegex = /^(\w+) (\w+\.cpp:\d+): (.*)$/;
|
// "Script @/path/to/file.lua:123: message"
|
||||||
|
// "Script =(command):123: message"
|
||||||
|
const secLogRegex = /^(\w+) ((\w+\.cpp:\d+)|([@=].*?:\d+)): (.*)$/;
|
||||||
let secLogMatch = secLogRegex.exec(secContent);
|
let secLogMatch = secLogRegex.exec(secContent);
|
||||||
if (secLogMatch) {
|
if (secLogMatch) {
|
||||||
output.type = "log";
|
output.type = "log";
|
||||||
output.level = secLogMatch[1];
|
output.level = secLogMatch[1];
|
||||||
output.file = secLogMatch[2];
|
output.file = secLogMatch[2];
|
||||||
output.message = secLogMatch[3];
|
output.message = secLogMatch[5];
|
||||||
|
|
||||||
// The other possibility is that the content is a generic message
|
// The other possibility is that the content is a generic message
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -83,7 +83,11 @@ function formatOutputColored(output, key) {
|
|||||||
let info = "";
|
let info = "";
|
||||||
if (output.type === "log") {
|
if (output.type === "log") {
|
||||||
let level = output.level;
|
let level = output.level;
|
||||||
if (level === "Info") {
|
if (level === "Script") {
|
||||||
|
level = <span className="factorio-script">{level}</span>;
|
||||||
|
} else if (level === "Verbose") {
|
||||||
|
level = <span className="factorio-verbose">{level}</span>;
|
||||||
|
} else if (level === "Info") {
|
||||||
level = <span className="factorio-info">{level}</span>;
|
level = <span className="factorio-info">{level}</span>;
|
||||||
} else if (output.level === "Warning") {
|
} else if (output.level === "Warning") {
|
||||||
level = <span className="factorio-warning">{level}</span>;
|
level = <span className="factorio-warning">{level}</span>;
|
||||||
|
|||||||
@@ -118,6 +118,16 @@ body {
|
|||||||
color: #808080;
|
color: #808080;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.instance-console .factorio-script {
|
||||||
|
font-weight: bold;
|
||||||
|
color: #49c33c;
|
||||||
|
}
|
||||||
|
|
||||||
|
.instance-console .factorio-verbose {
|
||||||
|
font-weight: bold;
|
||||||
|
color: #888888;
|
||||||
|
}
|
||||||
|
|
||||||
.instance-console .factorio-info {
|
.instance-console .factorio-info {
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
color: #4646ea;
|
color: #4646ea;
|
||||||
|
|||||||
@@ -143,6 +143,51 @@ let testLines = new Map([
|
|||||||
message: "Saving finished",
|
message: "Saving finished",
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
[
|
||||||
|
" 1.277 Script @/srv/clusterio/instances/test/temp/currently-playing/modules/example/test.lua:7: " +
|
||||||
|
"Example log line.",
|
||||||
|
{
|
||||||
|
format: "seconds",
|
||||||
|
time: "1.277",
|
||||||
|
type: "log",
|
||||||
|
level: "Script",
|
||||||
|
file: "@/srv/clusterio/instances/test/temp/currently-playing/modules/example/test.lua:7",
|
||||||
|
message: "Example log line.",
|
||||||
|
},
|
||||||
|
],
|
||||||
|
[
|
||||||
|
" 1.277 Script @C:\\My Cluster\\temp\\current-save\\file.lua:7: Contrived :12: example",
|
||||||
|
{
|
||||||
|
format: "seconds",
|
||||||
|
time: "1.277",
|
||||||
|
type: "log",
|
||||||
|
level: "Script",
|
||||||
|
file: "@C:\\My Cluster\\temp\\current-save\\file.lua:7",
|
||||||
|
message: "Contrived :12: example",
|
||||||
|
},
|
||||||
|
],
|
||||||
|
[
|
||||||
|
" 344.683 Script =(command):1: test",
|
||||||
|
{
|
||||||
|
format: "seconds",
|
||||||
|
time: "344.683",
|
||||||
|
type: "log",
|
||||||
|
level: "Script",
|
||||||
|
file: "=(command):1",
|
||||||
|
message: "test",
|
||||||
|
},
|
||||||
|
],
|
||||||
|
[
|
||||||
|
" 0.751 Verbose ModManager.cpp:554: Time to load mods: 0.746762",
|
||||||
|
{
|
||||||
|
format: "seconds",
|
||||||
|
time: "0.751",
|
||||||
|
type: "log",
|
||||||
|
level: "Verbose",
|
||||||
|
file: "ModManager.cpp:554",
|
||||||
|
message: "Time to load mods: 0.746762",
|
||||||
|
},
|
||||||
|
],
|
||||||
]);
|
]);
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
|
|||||||
Reference in new issue
Block a user