Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

writes errors to stderr from container #359

Open
wants to merge 4 commits into
base: 3.8
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ 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).

## [Unreleased] - 2022-01-22

### Fixes

- Run as container, errors are merged into stdout (instead of going to stderr)

## [3.8.0] - 2022-01-14

### Added
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/io/supertokens/output/Logging.java
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,9 @@ private Logger createLoggerForConsole(Main main, String name) {
ConsoleAppender<ILoggingEvent> logConsoleAppender = new ConsoleAppender<>();
logConsoleAppender.setEncoder(ple);
logConsoleAppender.setContext(lc);
if (name.startsWith("io.supertokens.Error")) {
logConsoleAppender.setTarget("System.err");
}
logConsoleAppender.start();

Logger logger = (Logger) LoggerFactory.getLogger(name);
Expand Down
8 changes: 4 additions & 4 deletions src/test/java/io/supertokens/test/LoggingTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ public void confirmLoggerClosed() throws Exception {
}

@Test
public void testStandardOutLoggingWithNullStr() throws Exception {
public void testStdoutStderrWithNullStr() throws Exception {
String[] args = { "../" };
ByteArrayOutputStream stdOutput = new ByteArrayOutputStream();
ByteArrayOutputStream errorOutput = new ByteArrayOutputStream();
Expand All @@ -192,7 +192,7 @@ public void testStandardOutLoggingWithNullStr() throws Exception {
Logging.error(process.getProcess(), "errTest-sdvjovnoasid", false);

assertTrue(fileContainsString(stdOutput, "outTest-dfkn3knsakn"));
assertTrue(fileContainsString(stdOutput, "errTest-sdvjovnoasid"));
assertTrue(fileContainsString(errorOutput, "errTest-sdvjovnoasid"));

} finally {
process.kill();
Expand All @@ -204,7 +204,7 @@ public void testStandardOutLoggingWithNullStr() throws Exception {
}

@Test
public void testStandardOutLoggingWithNull() throws Exception {
public void testStdoutStderrWithNull() throws Exception {
String[] args = { "../" };
ByteArrayOutputStream stdOutput = new ByteArrayOutputStream();
ByteArrayOutputStream errorOutput = new ByteArrayOutputStream();
Expand All @@ -225,7 +225,7 @@ public void testStandardOutLoggingWithNull() throws Exception {
Logging.error(process.getProcess(), "errTest-sdvjovnoasid", false);

assertTrue(fileContainsString(stdOutput, "outTest-dfkn3knsakn"));
assertTrue(fileContainsString(stdOutput, "errTest-sdvjovnoasid"));
assertTrue(fileContainsString(errorOutput, "errTest-sdvjovnoasid"));

} finally {
process.kill();
Expand Down