mirror of
https://github.com/SigNoz/signoz.git
synced 2025-12-23 02:17:11 +00:00
37 lines
889 B
TypeScript
37 lines
889 B
TypeScript
|
|
import { Color } from '@signozhq/design-tokens';
|
||
|
|
import { themeColors } from 'constants/theme';
|
||
|
|
import { colors } from 'lib/getRandomColor';
|
||
|
|
|
||
|
|
export function getColorsForSeverityLabels(
|
||
|
|
label: string,
|
||
|
|
index: number,
|
||
|
|
): string {
|
||
|
|
const lowerCaseLabel = label.toLowerCase();
|
||
|
|
|
||
|
|
if (lowerCaseLabel.includes(`{severity_text="trace"}`)) {
|
||
|
|
return Color.BG_ROBIN_300;
|
||
|
|
}
|
||
|
|
|
||
|
|
if (lowerCaseLabel.includes(`{severity_text="debug"}`)) {
|
||
|
|
return Color.BG_FOREST_500;
|
||
|
|
}
|
||
|
|
|
||
|
|
if (lowerCaseLabel.includes(`{severity_text="info"}`)) {
|
||
|
|
return Color.BG_SLATE_400;
|
||
|
|
}
|
||
|
|
|
||
|
|
if (lowerCaseLabel.includes(`{severity_text="warn"}`)) {
|
||
|
|
return Color.BG_AMBER_500;
|
||
|
|
}
|
||
|
|
|
||
|
|
if (lowerCaseLabel.includes(`{severity_text="error"}`)) {
|
||
|
|
return Color.BG_CHERRY_500;
|
||
|
|
}
|
||
|
|
|
||
|
|
if (lowerCaseLabel.includes(`{severity_text="fatal"}`)) {
|
||
|
|
return Color.BG_SAKURA_500;
|
||
|
|
}
|
||
|
|
|
||
|
|
return colors[index % colors.length] || themeColors.red;
|
||
|
|
}
|