mirror of
https://github.com/Akomry/sae302_applicom.git
synced 2025-12-06 08:43:54 +00:00
feat(graphique): Ajout logger, logging.properties, fonction initialize
This commit is contained in:
parent
8360fd9982
commit
6d8ec5b7f5
5 changed files with 55 additions and 2 deletions
|
|
@ -1,6 +1,7 @@
|
||||||
module rtgre.chat {
|
module rtgre.chat {
|
||||||
requires javafx.controls;
|
requires javafx.controls;
|
||||||
requires javafx.fxml;
|
requires javafx.fxml;
|
||||||
|
requires java.logging;
|
||||||
|
|
||||||
|
|
||||||
opens rtgre.chat to javafx.fxml;
|
opens rtgre.chat to javafx.fxml;
|
||||||
|
|
|
||||||
|
|
@ -6,8 +6,26 @@ import javafx.scene.Scene;
|
||||||
import javafx.stage.Stage;
|
import javafx.stage.Stage;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
import java.util.logging.LogManager;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
public class ChatApplication extends Application {
|
public class ChatApplication extends Application {
|
||||||
|
public static final Logger LOGGER = Logger.getLogger(ChatApplication.class.getCanonicalName());
|
||||||
|
public class EssaiLogger {
|
||||||
|
/* . . . */
|
||||||
|
static {
|
||||||
|
try {
|
||||||
|
InputStream is = EssaiLogger.class.getClassLoader()
|
||||||
|
.getResource("logging.properties").openStream();
|
||||||
|
LogManager.getLogManager().readConfiguration(is);
|
||||||
|
} catch (Exception e) {
|
||||||
|
LOGGER.log(Level.INFO, "Cannot read configuration file", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/* . . . */
|
||||||
|
}
|
||||||
@Override
|
@Override
|
||||||
public void start(Stage stage) throws IOException {
|
public void start(Stage stage) throws IOException {
|
||||||
FXMLLoader fxmlLoader = new FXMLLoader(ChatApplication.class.getResource("chat-view.fxml"));
|
FXMLLoader fxmlLoader = new FXMLLoader(ChatApplication.class.getResource("chat-view.fxml"));
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,16 @@
|
||||||
package rtgre.chat;
|
package rtgre.chat;
|
||||||
|
|
||||||
import javafx.fxml.FXML;
|
import javafx.fxml.FXML;
|
||||||
|
import javafx.fxml.Initializable;
|
||||||
import javafx.scene.control.*;
|
import javafx.scene.control.*;
|
||||||
import javafx.scene.image.ImageView;
|
import javafx.scene.image.ImageView;
|
||||||
|
|
||||||
public class ChatController {
|
import java.net.URL;
|
||||||
|
import java.util.ResourceBundle;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
import static rtgre.chat.ChatApplication.LOGGER;
|
||||||
|
public class ChatController implements Initializable {
|
||||||
|
|
||||||
public MenuItem hostAddMenuItem;
|
public MenuItem hostAddMenuItem;
|
||||||
public MenuItem avatarMenuItem;
|
public MenuItem avatarMenuItem;
|
||||||
|
|
@ -20,4 +25,8 @@ public class ChatController {
|
||||||
public ListView contactListView;
|
public ListView contactListView;
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void initialize(URL url, ResourceBundle resourceBundle) {
|
||||||
|
LOGGER.info("Initialisation de l'interface graphique");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -19,7 +19,7 @@
|
||||||
<?import javafx.scene.layout.RowConstraints?>
|
<?import javafx.scene.layout.RowConstraints?>
|
||||||
<?import javafx.scene.layout.VBox?>
|
<?import javafx.scene.layout.VBox?>
|
||||||
|
|
||||||
<VBox alignment="CENTER" minHeight="500.0" minWidth="800.0" prefHeight="500.0" prefWidth="800.0" xmlns:fx="http://javafx.com/fxml/1" xmlns="http://javafx.com/javafx/18" fx:controller="rtgre.chat.ChatController">
|
<VBox alignment="CENTER" minHeight="500.0" minWidth="800.0" prefHeight="500.0" prefWidth="800.0" xmlns="http://javafx.com/javafx/18" xmlns:fx="http://javafx.com/fxml/1" fx:controller="rtgre.chat.ChatController">
|
||||||
<children>
|
<children>
|
||||||
<MenuBar>
|
<MenuBar>
|
||||||
<menus>
|
<menus>
|
||||||
|
|
|
||||||
25
chat/src/main/resources/rtgre/chat/logging.properties
Normal file
25
chat/src/main/resources/rtgre/chat/logging.properties
Normal file
|
|
@ -0,0 +1,25 @@
|
||||||
|
# Les logs sont envoyés sur la console *et* dans un fichier
|
||||||
|
handlers=java.util.logging.ConsoleHandler, java.util.logging.FileHandler
|
||||||
|
|
||||||
|
# Configuration par défaut pour ConsoleHandler
|
||||||
|
# java.util.logging.ConsoleHandler.formatter=java.util.logging.SimpleFormatter
|
||||||
|
|
||||||
|
# Configuration de FileHandler. Par défaut,
|
||||||
|
# java.util.logging.FileHandler.formatter=java.util.logging.XMLFormater
|
||||||
|
java.util.logging.FileHandler.formatter=java.util.logging.SimpleFormatter
|
||||||
|
|
||||||
|
# Nom du fichier de logs
|
||||||
|
java.util.logging.FileHandler.pattern=out/java%u.log
|
||||||
|
|
||||||
|
# Format de logs plus compact sur 1 seule ligne
|
||||||
|
java.util.logging.SimpleFormatter.format=%1$tF %1$tT.%1$tL | %4$-7s | %2$s | %5$s %6$s%n
|
||||||
|
|
||||||
|
# niveaux : OFF / SEVERE / WARNING / INFO / CONFIG / FINE / FINER / FINEST / ALL
|
||||||
|
# Niveau global minimum pour les logs
|
||||||
|
.level=ALL
|
||||||
|
|
||||||
|
# Niveau minimum pour les logs sur la console
|
||||||
|
java.util.logging.ConsoleHandler.level=FINE
|
||||||
|
|
||||||
|
# Niveau minimum pour les logs dans le fichier
|
||||||
|
java.util.logging.FileHandler.level=ALL
|
||||||
Loading…
Add table
Add a link
Reference in a new issue