Skip to content

Commit 0cdd344

Browse files
authored
Merge pull request #119 from codecrafters-io/change-print-logs-to-stderr
CC-1469: Change all sample logs to print to stderr instead of stdout
2 parents 38f7597 + da022e7 commit 0cdd344

File tree

36 files changed

+36
-36
lines changed

36 files changed

+36
-36
lines changed

compiled_starters/cpp/src/Server.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ int main(int argc, char* argv[]) {
88
std::cerr << std::unitbuf;
99

1010
// You can use print statements as follows for debugging, they'll be visible when running tests.
11-
std::cout << "Logs from your program will appear here" << std::endl;
11+
std::cerr << "Logs from your program will appear here" << std::endl;
1212

1313
if (argc != 3) {
1414
std::cerr << "Expected two arguments" << std::endl;

compiled_starters/csharp/src/Program.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
if (command == ".dbinfo")
1515
{
1616
// You can use print statements as follows for debugging, they'll be visible when running tests.
17-
Console.WriteLine("Logs from your program will appear here!");
17+
Console.Error.WriteLine("Logs from your program will appear here!");
1818

1919
// Uncomment this line to pass the first stage
2020
// databaseFile.Seek(16, SeekOrigin.Begin); // Skip the first 16 bytes

compiled_starters/gleam/src/main.gleam

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import gleam/io
55

66
pub fn main() {
77
// You can use print statements as follows for debugging, they'll be visible when running tests.
8-
io.println("Logs from your program will appear here!")
8+
io.print_error("Logs from your program will appear here!\n")
99

1010
let args = argv.load().arguments
1111

compiled_starters/go/app/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ func main() {
3535
return
3636
}
3737
// You can use print statements as follows for debugging, they'll be visible when running tests.
38-
fmt.Println("Logs from your program will appear here!")
38+
fmt.Fprintln(os.Stderr, "Logs from your program will appear here!")
3939

4040
// Uncomment this to pass the first stage
4141
// fmt.Printf("database page size: %v", pageSize)

compiled_starters/java/src/main/java/Main.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public static void main(String[] args){
2525
int pageSize = Short.toUnsignedInt(pageSizeSigned);
2626

2727
// You can use print statements as follows for debugging, they'll be visible when running tests.
28-
System.out.println("Logs from your program will appear here!");
28+
System.err.println("Logs from your program will appear here!");
2929

3030
// Uncomment this block to pass the first stage
3131
// System.out.println("database page size: " + pageSize);

compiled_starters/javascript/app/main.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ if (command === ".dbinfo") {
1313
});
1414

1515
// You can use print statements as follows for debugging, they'll be visible when running tests.
16-
console.log("Logs from your program will appear here!");
16+
console.error("Logs from your program will appear here!");
1717

1818
// Uncomment this to pass the first stage
1919
// const pageSize = buffer.readUInt16BE(16); // page size is 2 bytes starting at offset 16

compiled_starters/python/app/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
if command == ".dbinfo":
1111
with open(database_file_path, "rb") as database_file:
1212
# You can use print statements as follows for debugging, they'll be visible when running tests.
13-
print("Logs from your program will appear here!")
13+
print("Logs from your program will appear here!", file=sys.stderr)
1414

1515
# Uncomment this to pass the first stage
1616
# database_file.seek(16) # Skip the first 16 bytes of the header

compiled_starters/ruby/app/main.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
if command == ".dbinfo"
55
File.open(database_file_path, "rb") do |database_file|
66
# You can use print statements as follows for debugging, they'll be visible when running tests.
7-
puts "Logs from your program will appear here"
7+
$stderr.puts "Logs from your program will appear here"
88

99
# Uncomment this to pass the first stage
1010
# database_file.seek(16) # Skip the first 16 bytes of the header

compiled_starters/rust/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ fn main() -> Result<()> {
2424
let page_size = u16::from_be_bytes([header[16], header[17]]);
2525

2626
// You can use print statements as follows for debugging, they'll be visible when running tests.
27-
println!("Logs from your program will appear here!");
27+
eprintln!("Logs from your program will appear here!");
2828

2929
// Uncomment this block to pass the first stage
3030
// println!("database page size: {}", page_size);

compiled_starters/swift/Sources/swift-sqlite-challenge/Main.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ struct Main {
1919
switch command {
2020
case ".dbinfo":
2121
// You can use print statements as follows for debugging, they'll be visible when running tests.
22-
print("Logs from your program will appear here!")
22+
eprintln("Logs from your program will appear here!")
2323

2424
// Uncomment this block to pass the first stage
2525
// let pageSize = UInt16(database[16..<18])

0 commit comments

Comments
 (0)