switch from pringln to using logging functions, enable file logging, turn on fancy colour as the auto-detect doesn't seem to work in my terminal (but the colour does) - wonder if I can fix the auto-detected rather than force the colour?

This commit is contained in:
Yvan 2025-01-25 11:37:46 +00:00
parent 06cb88f738
commit bb5d51b3c7
3 changed files with 18 additions and 8 deletions

View file

@ -7,8 +7,10 @@ import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.ui.Model; import org.springframework.ui.Model;
import java.util.List; import java.util.List;
import lombok.extern.slf4j.Slf4j;
@Controller @Controller
@Slf4j
public class BotController { public class BotController {
@Autowired @Autowired
@ -16,7 +18,7 @@ public class BotController {
@GetMapping("/viewbot") @GetMapping("/viewbot")
public String listAll(Model model) { public String listAll(Model model) {
System.out.println("WebHandler::viewbot"); log.info("WebHandler::viewbot");
List<Bot> botlist = botRepo.findAll(); List<Bot> botlist = botRepo.findAll();
model.addAttribute("bots", botlist); model.addAttribute("bots", botlist);
@ -26,7 +28,7 @@ public class BotController {
@GetMapping("/makebot") @GetMapping("/makebot")
public String makebotget(Model model) { public String makebotget(Model model) {
System.out.println("WebHandler::makebot"); log.info("WebHandler::makebot");
Bot bot = new Bot(); Bot bot = new Bot();
model.addAttribute("bot", bot); model.addAttribute("bot", bot);
@ -36,7 +38,7 @@ public class BotController {
@PostMapping("/makebot") @PostMapping("/makebot")
public String makebotpost(@ModelAttribute("bot") Bot bot) { public String makebotpost(@ModelAttribute("bot") Bot bot) {
System.out.println(bot); //log.info(bot);
botRepo.save(bot); botRepo.save(bot);

View file

@ -3,11 +3,15 @@ package dev.activitypub.activitypubbot;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import lombok.extern.slf4j.Slf4j;
import java.time.Instant;
import java.time.format.DateTimeFormatter;
/** /**
* Here we handle all non-JSON/REST requests - i.e. the normal "web" view * Here we handle all non-JSON/REST requests - i.e. the normal "web" view
*/ */
@Controller @Controller
@Slf4j
public class WebHandler { public class WebHandler {
@Autowired @Autowired
@ -19,12 +23,12 @@ public class WebHandler {
*/ */
@RequestMapping("/@springbot") @RequestMapping("/@springbot")
public String atactor() { public String atactor() {
System.out.println("WebHandler::atactor"); log.info("WebHandler::atactor");
return this.actor(); return this.actor();
} }
@RequestMapping("/users/springbot") @RequestMapping("/users/springbot")
public String actor() { public String actor() {
System.out.println("WebHandler::actor"); log.info("WebHandler::actor");
return "index"; // just flinging out the index page for now return "index"; // just flinging out the index page for now
} }
@ -33,19 +37,19 @@ public class WebHandler {
*/ */
@RequestMapping("/") @RequestMapping("/")
public String root() { public String root() {
System.out.println("WebHandler::root"); log.info("WebHandler::root");
return "index"; return "index";
} }
/* /*
// TODO: presumably there is some way to map things like /<string> to capture string and attempt to resolve template // TODO: presumably there is some way to map things like /<string> to capture string and attempt to resolve template
@RequestMapping("/viewbot") @RequestMapping("/viewbot")
public String viewbot() { public String viewbot() {
System.out.println("WebHandler::viewbot"); log.info("WebHandler::viewbot");
return "viewbot"; return "viewbot";
} }
@RequestMapping("/makebot") @RequestMapping("/makebot")
public String makebot() { public String makebot() {
System.out.println("WebHandler::makebot"); log.info("WebHandler::makebot");
return "makebot"; return "makebot";
} }
*/ */

View file

@ -2,6 +2,10 @@ spring.application.name=activitypubbot
springbot.domain=springbot.seth.id.au springbot.domain=springbot.seth.id.au
springbot.scheme=https springbot.scheme=https
logging.file.name=logs/springbot.log
logging.file.path=logs
spring.output.ansi.enabled=ALWAYS
spring.mvc.view.prefix: /WEB-INF/views/ spring.mvc.view.prefix: /WEB-INF/views/
spring.mvc.view.suffix: .jsp spring.mvc.view.suffix: .jsp