Skip to content

Conversation

@difagume
Copy link
Contributor

@difagume difagume commented Dec 4, 2025

  • Added support for detecting warning symbols (⚠, ⚠️) in log messages

What is this PR about?

This PR fixes an issue where certain warning messages containing visual warning symbols (⚠, ⚠️) were incorrectly classified as info logs.
The log detection logic has been updated to properly recognize these characters as warning indicators.
With this change, logs that include these symbols are now correctly categorized and styled as warning.

You can test the updated behavior here:
Playground Link

Checklist

Before submitting this PR, please make sure that:

Screenshots

image

- Added support for detecting warning symbols (⚠, ⚠️) in log messages
@difagume difagume requested a review from Siumauricio as a code owner December 4, 2025 16:45
@SteadEXE
Copy link
Contributor

SteadEXE commented Dec 5, 2025

I think it might be a good idea to convert those conditions into arrays, conditions start to get messy

@190km
Copy link

190km commented Dec 5, 2025

I think it might be a good idea to convert those conditions into arrays, conditions start to get messy

right, like this it should be way better

type LogType = "error" | "warning" | "success" | "info" | "debug";
type LogVariant = "red" | "yellow" | "green" | "blue" | "orange";

interface LogStyle {
	type: LogType;
	variant: LogVariant;
	color: string;
}

const LOG_STYLES: Record<LogType, LogStyle> = {
	error: { type: "error", variant: "red", color: "bg-red-500/40" },
	warning: { type: "warning", variant: "orange", color: "bg-orange-500/40" },
	debug: { type: "debug", variant: "yellow", color: "bg-yellow-500/40" },
	success: { type: "success", variant: "green", color: "bg-green-500/40" },
	info: { type: "info", variant: "blue", color: "bg-blue-600/40" },
} as const;


const PATTERNS = {
	error: [
		/(?:^|\s)(?:error|err|fatal|crit|critical):?\s/i,
		/\b(?:exception|crash|failed|failure|uncaught|unhandled)\b/i,
		/stack\s?trace/i,
		/Error:\s/,
		/\[(?:error|err|fatal)\]/i,
		/errno/i,
		/|🚫/
	],
	warning: [
		/(?:^|\s)(?:warn|warning|attention|caution):?\s/i,
		/\[(?:warn|warning)\]/i,
		/\b(?:deprecated|obsolete|unstable|experimental)\b/i,
		/||🔶|🔸/ 
	],
	success: [
		/(?:^|\s)(?:success|succeed|succeeded):?\s/i,
		/\b(?:successfully|completed|done|deployed|mounted|loaded)\b/i,
		/\[(?:ok|success|done)\]/i,
		/(?:listening|running)\s+on/i,
		/|||/
	],
	debug: [
		/(?:^|\s)(?:debug|dbg|trace):?\s/i,
		/\[(?:debug|trace|http)\]/i,
		/\b(?:GET|POST|PUT|PATCH|DELETE)\b/ 
	]
};

const matchesAny = (text: string, patterns: RegExp[]): boolean => {
	return patterns.some((regex) => regex.test(text));
};

const getLogType = (message: string): LogStyle => {
	if (!message) return LOG_STYLES.info;

	if (matchesAny(message, PATTERNS.error)) {
		return LOG_STYLES.error;
	}

	if (matchesAny(message, PATTERNS.warning)) {
		return LOG_STYLES.warning;
	}

	if (matchesAny(message, PATTERNS.success)) {
		return LOG_STYLES.success;
	}

	if (matchesAny(message, PATTERNS.debug)) {
		return LOG_STYLES.debug;
	}
	return LOG_STYLES.info;
};

@Siumauricio Siumauricio merged commit 84e0f58 into Dokploy:canary Dec 21, 2025
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants