Skip to content

Commit

Permalink
fix: error logs should be printed to StdErr
Browse files Browse the repository at this point in the history
  • Loading branch information
anku255 committed Feb 5, 2024
1 parent c1800ab commit 3300f40
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres
to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [7.0.17] - 2024-02-06

- Fixes issue where error logs were printed to StdOut instead of StdErr.

## [7.0.16] - 2023-12-04

- Returns 400, instead of 500, for badly typed core config while creating CUD, App or Tenant
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ compileTestJava { options.encoding = "UTF-8" }
// }
//}

version = "7.0.16"
version = "7.0.17"


repositories {
Expand Down
7 changes: 4 additions & 3 deletions src/main/java/io/supertokens/output/Logging.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,11 @@ public class Logging extends ResourceDistributor.SingletonResource {

private Logging(Main main) {
this.infoLogger = Config.getBaseConfig(main).getInfoLogPath(main).equals("null")
? createLoggerForConsole(main, "io.supertokens.Info")
? createLoggerForConsole(main, "io.supertokens.Info", LOG_LEVEL.INFO)
: createLoggerForFile(main, Config.getBaseConfig(main).getInfoLogPath(main),
"io.supertokens.Info");
this.errorLogger = Config.getBaseConfig(main).getErrorLogPath(main).equals("null")
? createLoggerForConsole(main, "io.supertokens.Error")
? createLoggerForConsole(main, "io.supertokens.Error", LOG_LEVEL.ERROR)
: createLoggerForFile(main, Config.getBaseConfig(main).getErrorLogPath(main),
"io.supertokens.Error");
Storage storage = StorageLayer.getBaseStorage(main);
Expand Down Expand Up @@ -250,12 +250,13 @@ private Logger createLoggerForFile(Main main, String file, String name) {
return logger;
}

private Logger createLoggerForConsole(Main main, String name) {
private Logger createLoggerForConsole(Main main, String name, LOG_LEVEL logLevel) {
LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory();
LayoutWrappingEncoder ple = new LayoutWrappingEncoder(main.getProcessId());
ple.setContext(lc);
ple.start();
ConsoleAppender<ILoggingEvent> logConsoleAppender = new ConsoleAppender<>();
logConsoleAppender.setTarget(logLevel == LOG_LEVEL.ERROR ? "System.err" : "System.out");
logConsoleAppender.setEncoder(ple);
logConsoleAppender.setContext(lc);
logConsoleAppender.start();
Expand Down

0 comments on commit 3300f40

Please sign in to comment.