Compare commits

...

10 Commits

12 changed files with 103 additions and 148 deletions

View File

@ -40,6 +40,23 @@ cd front
pnpm run unlink_kar_cw pnpm run unlink_kar_cw
``` ```
Tools in production mode
========================
Changing the Log Level
----------------------
In a production environment, you can adjust the log level to help diagnose bugs more effectively.
The available log levels are:
| **Log Level Tag** | **org.kar.karusic** | **org.kar.archidata** | **other** |
| ----------------- | ------------------- | --------------------- | --------- |
| `prod` | INFO | INFO | INFO |
| `prod-debug` | DEBUG | INFO | INFO |
| `prod-trace` | TRACE | DEBUG | INFO |
| `prod-trace-full` | TRACE | TRACE | INFO |
| `dev` | TRACE | DEBUG | INFO |
Manual set in production: Manual set in production:
========================= =========================

View File

@ -20,7 +20,7 @@
<dependency> <dependency>
<groupId>kangaroo-and-rabbit</groupId> <groupId>kangaroo-and-rabbit</groupId>
<artifactId>archidata</artifactId> <artifactId>archidata</artifactId>
<version>0.20.4</version> <version>0.21.0</version>
</dependency> </dependency>
<!-- Loopback of logger JDK logging API to SLF4J --> <!-- Loopback of logger JDK logging API to SLF4J -->
<dependency> <dependency>
@ -39,6 +39,11 @@
<artifactId>xercesImpl</artifactId> <artifactId>xercesImpl</artifactId>
<version>2.12.2</version> <version>2.12.2</version>
</dependency> </dependency>
<dependency>
<groupId>org.codehaus.janino</groupId>
<artifactId>janino</artifactId>
<version>3.1.9</version>
</dependency>
<dependency> <dependency>
<groupId>com.fasterxml.jackson.datatype</groupId> <groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-jsr310</artifactId> <artifactId>jackson-datatype-jsr310</artifactId>

View File

@ -1,60 +0,0 @@
package org.kar.karusic.internal;
//import io.scenarium.logger.LogLevel;
//import io.scenarium.logger.Logger;
public class Log {
// private static final String LIB_NAME = "logger";
// private static final String LIB_NAME_DRAW = Logger.getDrawableName(LIB_NAME);
// private static final boolean PRINT_CRITICAL = Logger.getNeedPrint(LIB_NAME, LogLevel.CRITICAL);
// private static final boolean PRINT_ERROR = Logger.getNeedPrint(LIB_NAME, LogLevel.ERROR);
// private static final boolean PRINT_WARNING = Logger.getNeedPrint(LIB_NAME, LogLevel.WARNING);
// private static final boolean PRINT_INFO = Logger.getNeedPrint(LIB_NAME, LogLevel.INFO);
// private static final boolean PRINT_DEBUG = Logger.getNeedPrint(LIB_NAME, LogLevel.DEBUG);
// private static final boolean PRINT_VERBOSE = Logger.getNeedPrint(LIB_NAME, LogLevel.VERBOSE);
// private static final boolean PRINT_TODO = Logger.getNeedPrint(LIB_NAME, LogLevel.TODO);
// private static final boolean PRINT_PRINT = Logger.getNeedPrint(LIB_NAME, LogLevel.PRINT);
//
// private Log() {}
//
// public static void print(String data) {
// if (PRINT_PRINT)
// Logger.print(LIB_NAME_DRAW, data);
// }
//
// public static void todo(String data) {
// if (PRINT_TODO)
// Logger.todo(LIB_NAME_DRAW, data);
// }
//
// public static void critical(String data) {
// if (PRINT_CRITICAL)
// Logger.critical(LIB_NAME_DRAW, data);
// }
//
// public static void error(String data) {
// if (PRINT_ERROR)
// Logger.error(LIB_NAME_DRAW, data);
// }
//
// public static void warning(String data) {
// if (PRINT_WARNING)
// Logger.warning(LIB_NAME_DRAW, data);
// }
//
// public static void info(String data) {
// if (PRINT_INFO)
// Logger.info(LIB_NAME_DRAW, data);
// }
//
// public static void debug(String data) {
// if (PRINT_DEBUG)
// Logger.debug(LIB_NAME_DRAW, data);
// }
//
// public static void verbose(String data) {
// if (PRINT_VERBOSE)
// Logger.verbose(LIB_NAME_DRAW, data);
// }
}

View File

@ -18,21 +18,18 @@ public class Initialization extends MigrationSqlStep {
private static final Logger LOGGER = LoggerFactory.getLogger(Initialization.class); private static final Logger LOGGER = LoggerFactory.getLogger(Initialization.class);
public static final int KARSO_INITIALISATION_ID = 1; public static final int KARSO_INITIALISATION_ID = 1;
public static final List<Class<?>> CLASSES_BASE = List.of(Album.class, Artist.class, Data.class, Gender.class, Playlist.class, Track.class, User.class); public static final List<Class<?>> CLASSES_BASE = List.of(Album.class, Artist.class, Data.class, Gender.class,
Playlist.class, Track.class, User.class);
@Override @Override
public String getName() { public String getName() {
return "Initialization"; return "Initialization";
} }
public Initialization() {
}
@Override @Override
public void generateStep() throws Exception { public void generateStep() throws Exception {
for (final Class<?> elem : CLASSES_BASE) { for (final Class<?> clazz : CLASSES_BASE) {
addClass(elem); addClass(clazz);
} }
addAction((final DBAccess da) -> { addAction((final DBAccess da) -> {
@ -63,6 +60,7 @@ public class Initialization extends MigrationSqlStep {
new Gender(24L, "Bande Originale"), // new Gender(24L, "Bande Originale"), //
new Gender(25L, "Variété Belge"), // new Gender(25L, "Variété Belge"), //
new Gender(26L, "Gospel")); new Gender(26L, "Gospel"));
da.insertMultiple(data);
}); });
// set start increment element to permit to add after default elements // set start increment element to permit to add after default elements
addAction(""" addAction("""

View File

@ -1,18 +1,50 @@
<?xml version="1.0" encoding="UTF-8"?>
<configuration> <configuration>
<!-- environment detection (defaut: dev) -->
<property name="LOG_LEVEL_ENV" value="${LOG_LEVEL:-dev}" />
<!-- Appender for development -->
<if condition="property(&quot;LOG_LEVEL_ENV&quot;).equals(&quot;dev&quot;)">
<then>
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender"> <appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
<encoder> <encoder>
<pattern> <pattern>%green(%d{HH:mm:ss.SSS}) %highlight(%-5level) %-30((%file:%line\)): %msg%n</pattern>
%d{HH:mm:ss.SSS} [%thread] %highlight(%-5level) %logger - %msg%n
</pattern>
<!--
<pattern>
%d{HH:mm:ss.SSS} | %thread | %highlight(%-5level) | %logger - %msg%n
</pattern>
-->
</encoder> </encoder>
</appender> </appender>
<logger name="org.kar.karusic" level="TRACE" />
<root level="info"> <logger name="org.kar.archidata" level="DEBUG" />
<root level="INFO">
<appender-ref ref="CONSOLE" /> <appender-ref ref="CONSOLE" />
</root> </root>
</then>
</if>
<!-- Appender for production -->
<if condition="property(&quot;LOG_LEVEL_ENV&quot;).matches(&quot;^prod.*&quot;)">
<then>
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>[%thread] %level %logger - %msg%n</pattern>
</encoder>
</appender>
<root level="INFO">
<appender-ref ref="CONSOLE" />
</root>
</then>
</if>
<if condition="property(&quot;LOG_LEVEL_ENV&quot;).equals(&quot;prod-debug&quot;)">
<then>
<logger name="org.kar.karusic" level="DEBUG" />
</then>
</if>
<if condition="property(&quot;LOG_LEVEL_ENV&quot;).equals(&quot;prod-trace&quot;)">
<then>
<logger name="org.kar.karusic" level="TRACE" />
<logger name="org.kar.archidata" level="DEBUG" />
</then>
</if>
<if condition="property(&quot;LOG_LEVEL_ENV&quot;).equals(&quot;prod-trace-full&quot;)">
<then>
<logger name="org.kar.karusic" level="TRACE" />
<logger name="org.kar.archidata" level="TRACE" />
</then>
</if>
</configuration> </configuration>

View File

@ -1,42 +0,0 @@
# SLF4J's SimpleLogger configuration file
# Simple implementation of Logger that sends all enabled log messages, for all defined loggers, to System.err.
# Default logging detail level for all instances of SimpleLogger.
# Must be one of ("trace", "debug", "info", "warn", or "error").
# If not specified, defaults to "info".
org.slf4j.simpleLogger.defaultLogLevel=INFO
# Logging detail level for a SimpleLogger instance named "xxxxx".
# Must be one of ("trace", "debug", "info", "warn", or "error").
# If not specified, the default logging detail level is used.
#org.slf4j.simpleLogger.log.xxxxx=
org.slf4j.simpleLogger.log.org.kar.archidata=TRACE
org.slf4j.simpleLogger.log.org.kar.karusic=TRACE
# Set to true if you want the current date and time to be included in output messages.
# Default is false, and will output the number of milliseconds elapsed since startup.
#org.slf4j.simpleLogger.showDateTime=false
# The date and time format to be used in the output messages.
# The pattern describing the date and time format is the same that is used in java.text.SimpleDateFormat.
# If the format is not specified or is invalid, the default format is used.
# The default format is yyyy-MM-dd HH:mm:ss:SSS Z.
#org.slf4j.simpleLogger.dateTimeFormat=yyyy-MM-dd HH:mm:ss:SSS Z
# Set to true if you want to output the current thread name.
# Defaults to true.
org.slf4j.simpleLogger.showThreadName=true
# Set to true if you want the Logger instance name to be included in output messages.
# Defaults to true.
#org.slf4j.simpleLogger.showLogName=true
# Set to true if you want the last component of the name to be included in output messages.
# Defaults to false.
#org.slf4j.simpleLogger.showShortLogName=false
# Utilise les codes ANSI pour la couleur
org.slf4j.simpleLogger.warnColor=\u001B[33m
org.slf4j.simpleLogger.errorColor=\u001B[31m
org.slf4j.simpleLogger.infoColor=\u001B[32m
org.slf4j.simpleLogger.debugColor=\u001B[34m

View File

@ -35,6 +35,10 @@ public class ConfigureDb {
if (modeTestForced != null) { if (modeTestForced != null) {
modeTest = modeTestForced; modeTest = modeTestForced;
} }
// for local test:
ConfigBaseVariable.apiAdress = "http://127.0.0.1:12342/test/api/";
// Enable the test mode permit to access to the test token (never use it in production).
ConfigBaseVariable.testMode = "true";
final List<Class<?>> listObject = List.of( // final List<Class<?>> listObject = List.of( //
Album.class, // Album.class, //
Artist.class, // Artist.class, //

View File

@ -25,8 +25,6 @@ public class TestBase {
ConfigureDb.configure(); ConfigureDb.configure();
LOGGER.info("configure server ..."); LOGGER.info("configure server ...");
webInterface = new WebLauncherTest(); webInterface = new WebLauncherTest();
LOGGER.info("Clean previous table");
LOGGER.info("Start REST (BEGIN)"); LOGGER.info("Start REST (BEGIN)");
webInterface.process(); webInterface.process();
LOGGER.info("Start REST (DONE)"); LOGGER.info("Start REST (DONE)");

View File

@ -12,7 +12,8 @@
"node": ">=20" "node": ">=20"
}, },
"scripts": { "scripts": {
"update_packages": "ncu --upgrade", "update_packages": "ncu --target minor",
"upgrade_packages": "ncu --upgrade --rejectVersion \"/^[~^<>]| - |\\.x$/\" ",
"install_dependency": "pnpm install", "install_dependency": "pnpm install",
"test": "vitest run", "test": "vitest run",
"test:watch": "vitest watch", "test:watch": "vitest watch",
@ -28,18 +29,18 @@
"*.{ts,tsx,js,jsx,json}": "prettier --write" "*.{ts,tsx,js,jsx,json}": "prettier --write"
}, },
"dependencies": { "dependencies": {
"@chakra-ui/anatomy": "2.2.2", "@chakra-ui/anatomy": "~2.2.2",
"@chakra-ui/cli": "2.4.1", "@chakra-ui/cli": "~2.4.1",
"@chakra-ui/react": "2.8.2", "@chakra-ui/react": "~2.8.2",
"@chakra-ui/theme-tools": "2.2.6", "@chakra-ui/theme-tools": "~2.2.6",
"@dnd-kit/core": "6.3.1", "@dnd-kit/core": "6.3.1",
"@dnd-kit/modifiers": "9.0.0", "@dnd-kit/modifiers": "9.0.0",
"@dnd-kit/sortable": "10.0.0", "@dnd-kit/sortable": "10.0.0",
"@dnd-kit/utilities": "3.2.2", "@dnd-kit/utilities": "3.2.2",
"@emotion/react": "11.14.0", "@emotion/react": "11.14.0",
"@emotion/styled": "11.14.0", "@emotion/styled": "11.14.0",
"@formiz/core": "2.4.5", "@formiz/core": "^2.4.5",
"@formiz/validations": "2.0.1", "@formiz/validations": "^2.0.1",
"allotment": "1.20.2", "allotment": "1.20.2",
"css-mediaquery": "0.1.2", "css-mediaquery": "0.1.2",
"dayjs": "1.11.13", "dayjs": "1.11.13",
@ -67,7 +68,7 @@
"zustand": "5.0.2" "zustand": "5.0.2"
}, },
"devDependencies": { "devDependencies": {
"@chakra-ui/styled-system": "2.12.0", "@chakra-ui/styled-system": "^2.12.0",
"@playwright/test": "1.49.1", "@playwright/test": "1.49.1",
"@storybook/addon-actions": "8.4.7", "@storybook/addon-actions": "8.4.7",
"@storybook/addon-essentials": "8.4.7", "@storybook/addon-essentials": "8.4.7",

16
front/pnpm-lock.yaml generated
View File

@ -9,16 +9,16 @@ importers:
.: .:
dependencies: dependencies:
'@chakra-ui/anatomy': '@chakra-ui/anatomy':
specifier: 2.2.2 specifier: ^2.2.2
version: 2.2.2 version: 2.3.4
'@chakra-ui/cli': '@chakra-ui/cli':
specifier: 2.4.1 specifier: ^2.4.1
version: 2.4.1 version: 2.4.1
'@chakra-ui/react': '@chakra-ui/react':
specifier: 2.8.2 specifier: ^2.8.2
version: 2.8.2(@emotion/react@11.14.0(@types/react@18.3.8)(react@18.3.1))(@emotion/styled@11.14.0(@emotion/react@11.14.0(@types/react@18.3.8)(react@18.3.1))(@types/react@18.3.8)(react@18.3.1))(@types/react@18.3.8)(framer-motion@11.15.0(@emotion/is-prop-valid@1.3.1)(react-dom@18.3.1(react@18.3.1))(react@18.3.1))(react-dom@18.3.1(react@18.3.1))(react@18.3.1) version: 2.8.2(@emotion/react@11.14.0(@types/react@18.3.8)(react@18.3.1))(@emotion/styled@11.14.0(@emotion/react@11.14.0(@types/react@18.3.8)(react@18.3.1))(@types/react@18.3.8)(react@18.3.1))(@types/react@18.3.8)(framer-motion@11.15.0(@emotion/is-prop-valid@1.3.1)(react-dom@18.3.1(react@18.3.1))(react@18.3.1))(react-dom@18.3.1(react@18.3.1))(react@18.3.1)
'@chakra-ui/theme-tools': '@chakra-ui/theme-tools':
specifier: 2.2.6 specifier: ^2.2.6
version: 2.2.6(@chakra-ui/styled-system@2.12.0(react@18.3.1))(react@18.3.1) version: 2.2.6(@chakra-ui/styled-system@2.12.0(react@18.3.1))(react@18.3.1)
'@dnd-kit/core': '@dnd-kit/core':
specifier: 6.3.1 specifier: 6.3.1
@ -39,10 +39,10 @@ importers:
specifier: 11.14.0 specifier: 11.14.0
version: 11.14.0(@emotion/react@11.14.0(@types/react@18.3.8)(react@18.3.1))(@types/react@18.3.8)(react@18.3.1) version: 11.14.0(@emotion/react@11.14.0(@types/react@18.3.8)(react@18.3.1))(@types/react@18.3.8)(react@18.3.1)
'@formiz/core': '@formiz/core':
specifier: 2.4.5 specifier: ^2.4.5
version: 2.4.5(react@18.3.1) version: 2.4.5(react@18.3.1)
'@formiz/validations': '@formiz/validations':
specifier: 2.0.1 specifier: ^2.0.1
version: 2.0.1 version: 2.0.1
allotment: allotment:
specifier: 1.20.2 specifier: 1.20.2
@ -121,7 +121,7 @@ importers:
version: 5.0.2(@types/react@18.3.8)(react@18.3.1)(use-sync-external-store@1.2.2(react@18.3.1)) version: 5.0.2(@types/react@18.3.8)(react@18.3.1)(use-sync-external-store@1.2.2(react@18.3.1))
devDependencies: devDependencies:
'@chakra-ui/styled-system': '@chakra-ui/styled-system':
specifier: 2.12.0 specifier: ^2.12.0
version: 2.12.0(react@18.3.1) version: 2.12.0(react@18.3.1)
'@playwright/test': '@playwright/test':
specifier: 1.49.1 specifier: 1.49.1

View File

@ -3,11 +3,11 @@
*/ */
import { z as zod } from "zod"; import { z as zod } from "zod";
import {ZodUUID} from "./uuid"; import {ZodObjectId} from "./object-id";
import {ZodInteger} from "./integer"; import {ZodInteger} from "./integer";
export const ZodRestErrorResponse = zod.object({ export const ZodRestErrorResponse = zod.object({
uuid: ZodUUID.optional(), oid: ZodObjectId.optional(),
name: zod.string(), name: zod.string(),
message: zod.string(), message: zod.string(),
time: zod.string(), time: zod.string(),

View File

@ -80,7 +80,6 @@ const environment_hybrid: Environment = {
tokenStoredInPermanentStorage: false, tokenStoredInPermanentStorage: false,
}; };
export const environment = environment_local;
/** /**
* Check if the current environment is for development * Check if the current environment is for development
@ -90,6 +89,9 @@ export const isDevelopmentEnvironment = () => {
return import.meta.env.MODE === 'development'; return import.meta.env.MODE === 'development';
}; };
export const environment = isDevelopmentEnvironment() ? environment_local : environment_back_prod;
/** /**
* get the current REST api URL. Depend on the VITE_API_BASE_URL env variable. * get the current REST api URL. Depend on the VITE_API_BASE_URL env variable.
* @returns The URL with http(s)://*** * @returns The URL with http(s)://***