Skip to content

Commit

Permalink
Merge pull request #123 from codecrafters-io/change-print-logs-to-stderr
Browse files Browse the repository at this point in the history
CC-1469: Change all sample logs to print to stderr instead of stdout
  • Loading branch information
andy1li authored Oct 28, 2024
2 parents 01b280d + c476b11 commit 7819e06
Show file tree
Hide file tree
Showing 33 changed files with 33 additions and 33 deletions.
2 changes: 1 addition & 1 deletion compiled_starters/cpp/src/Server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ int main(int argc, char *argv[])
std::cerr << std::unitbuf;

// You can use print statements as follows for debugging, they'll be visible when running tests.
std::cout << "Logs from your program will appear here!\n";
std::cerr << "Logs from your program will appear here!\n";

// Uncomment this block to pass the first stage
//
Expand Down
2 changes: 1 addition & 1 deletion compiled_starters/csharp/src/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
}

// You can use print statements as follows for debugging, they'll be visible when running tests.
Console.WriteLine("Logs from your program will appear here!");
Console.Error.WriteLine("Logs from your program will appear here!");

string command = args[0];

Expand Down
2 changes: 1 addition & 1 deletion compiled_starters/go/cmd/mygit/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
// Usage: your_program.sh <command> <arg1> <arg2> ...
func main() {
// You can use print statements as follows for debugging, they'll be visible when running tests.
fmt.Println("Logs from your program will appear here!")
fmt.Fprintf(os.Stderr, "Logs from your program will appear here!\n")

if len(os.Args) < 2 {
fmt.Fprintf(os.Stderr, "usage: mygit <command> [<args>...]\n")
Expand Down
2 changes: 1 addition & 1 deletion compiled_starters/haskell/app/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import System.IO (IOMode (WriteMode), hPutStrLn, withFile)
main :: IO ()
main = do
-- You can use print statements as follows for debugging, they'll be visible when running tests.
putStrLn "Logs from your program will appear here"
hPutStrLn stderr "Logs from your program will appear here"

-- Uncomment this block to pass first stage
-- let createParents = True
Expand Down
2 changes: 1 addition & 1 deletion compiled_starters/java/src/main/java/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
public class Main {
public static void main(String[] args){
// You can use print statements as follows for debugging, they'll be visible when running tests.
System.out.println("Logs from your program will appear here!");
System.err.println("Logs from your program will appear here!");

// Uncomment this block to pass the first stage
//
Expand Down
2 changes: 1 addition & 1 deletion compiled_starters/javascript/app/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const fs = require("fs");
const path = require("path");

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

// Uncomment this block to pass the first stage
// const command = process.argv[2];
Expand Down
2 changes: 1 addition & 1 deletion compiled_starters/python/app/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

def main():
# You can use print statements as follows for debugging, they'll be visible when running tests.
print("Logs from your program will appear here!")
print("Logs from your program will appear here!", file=sys.stderr)

# Uncomment this block to pass the first stage
#
Expand Down
2 changes: 1 addition & 1 deletion compiled_starters/ruby/app/main.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# You can use print statements as follows for debugging, they'll be visible when running tests.
puts "Logs from your program will appear here!"
$stderr.puts "Logs from your program will appear here!"

# Uncomment this block to pass the first stage
#
Expand Down
2 changes: 1 addition & 1 deletion compiled_starters/rust/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use std::fs;

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

// Uncomment this block to pass the first stage
// let args: Vec<String> = env::args().collect();
Expand Down
2 changes: 1 addition & 1 deletion compiled_starters/typescript/app/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ enum Commands {
switch (command) {
case Commands.Init:
// You can use print statements as follows for debugging, they'll be visible when running tests.
console.log("Logs from your program will appear here!");
console.error("Logs from your program will appear here!");

// Uncomment this block to pass the first stage
// fs.mkdirSync(".git", { recursive: true });
Expand Down
2 changes: 1 addition & 1 deletion compiled_starters/zig/src/main.zig
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ pub fn main() !void {
const command: []const u8 = args[1];

// You can use print statements as follows for debugging, they'll be visible when running tests.
try stdout.print("Logs from your program will appear here\n", .{});
std.debug.print("Logs from your program will appear here!\n", .{});

if (std.mem.eql(u8, command, "init")) {
// Uncomment this block to pass the first stage
Expand Down
2 changes: 1 addition & 1 deletion solutions/cpp/01-gg4/diff/src/Server.cpp.diff
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
std::cerr << std::unitbuf;

- // You can use print statements as follows for debugging, they'll be visible when running tests.
- std::cout << "Logs from your program will appear here!\n";
- std::cerr << "Logs from your program will appear here!\n";
+ if (argc < 2) {
+ std::cerr << "No command provided.\n";
+ return EXIT_FAILURE;
Expand Down
2 changes: 1 addition & 1 deletion solutions/csharp/01-gg4/diff/src/Program.cs.diff
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
}

-// You can use print statements as follows for debugging, they'll be visible when running tests.
-Console.WriteLine("Logs from your program will appear here!");
-Console.Error.WriteLine("Logs from your program will appear here!");
-
string command = args[0];

Expand Down
2 changes: 1 addition & 1 deletion solutions/go/01-gg4/diff/cmd/mygit/main.go.diff
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
// Usage: your_program.sh <command> <arg1> <arg2> ...
func main() {
- // You can use print statements as follows for debugging, they'll be visible when running tests.
- fmt.Println("Logs from your program will appear here!")
- fmt.Fprintf(os.Stderr, "Logs from your program will appear here!\n")
-
if len(os.Args) < 2 {
fmt.Fprintf(os.Stderr, "usage: mygit <command> [<args>...]\n")
Expand Down
2 changes: 1 addition & 1 deletion solutions/haskell/01-gg4/diff/app/Main.hs.diff
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
main :: IO ()
main = do
- -- You can use print statements as follows for debugging, they'll be visible when running tests.
- putStrLn "Logs from your program will appear here"
- hPutStrLn stderr "Logs from your program will appear here"
-
- -- Uncomment this block to pass first stage
- -- let createParents = True
Expand Down
2 changes: 1 addition & 1 deletion solutions/java/01-gg4/diff/src/main/java/Main.java.diff
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
public class Main {
public static void main(String[] args){
- // You can use print statements as follows for debugging, they'll be visible when running tests.
- System.out.println("Logs from your program will appear here!");
- System.err.println("Logs from your program will appear here!");
+ final String command = args[0];

- // Uncomment this block to pass the first stage
Expand Down
2 changes: 1 addition & 1 deletion solutions/javascript/01-gg4/diff/app/main.js.diff
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
const path = require("path");

-// You can use print statements as follows for debugging, they'll be visible when running tests.
-console.log("Logs from your program will appear here!");
-console.error("Logs from your program will appear here!");
+const command = process.argv[2];

-// Uncomment this block to pass the first stage
Expand Down
2 changes: 1 addition & 1 deletion solutions/python/01-gg4/diff/app/main.py.diff
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

def main():
- # You can use print statements as follows for debugging, they'll be visible when running tests.
- print("Logs from your program will appear here!")
- print("Logs from your program will appear here!", file=sys.stderr)
-
- # Uncomment this block to pass the first stage
- #
Expand Down
2 changes: 1 addition & 1 deletion solutions/ruby/01-gg4/diff/app/main.rb.diff
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
@@ -1,16 +1,11 @@
-# You can use print statements as follows for debugging, they'll be visible when running tests.
-puts "Logs from your program will appear here!"
-$stderr.puts "Logs from your program will appear here!"
-
-# Uncomment this block to pass the first stage
-#
Expand Down
2 changes: 1 addition & 1 deletion solutions/rust/01-gg4/diff/src/main.rs.diff
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

fn main() {
- // You can use print statements as follows for debugging, they'll be visible when running tests.
- println!("Logs from your program will appear here!");
- eprintln!("Logs from your program will appear here!");
-
- // Uncomment this block to pass the first stage
- // let args: Vec<String> = env::args().collect();
Expand Down
2 changes: 1 addition & 1 deletion solutions/typescript/01-gg4/diff/app/main.ts.diff
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
switch (command) {
case Commands.Init:
- // You can use print statements as follows for debugging, they'll be visible when running tests.
- console.log("Logs from your program will appear here!");
- console.error("Logs from your program will appear here!");
-
- // Uncomment this block to pass the first stage
- // fs.mkdirSync(".git", { recursive: true });
Expand Down
2 changes: 1 addition & 1 deletion solutions/zig/01-gg4/diff/src/main.zig.diff
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
const command: []const u8 = args[1];

- // You can use print statements as follows for debugging, they'll be visible when running tests.
- try stdout.print("Logs from your program will appear here\n", .{});
- std.debug.print("Logs from your program will appear here!\n", .{});
-
if (std.mem.eql(u8, command, "init")) {
- // Uncomment this block to pass the first stage
Expand Down
2 changes: 1 addition & 1 deletion starter_templates/cpp/code/src/Server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ int main(int argc, char *argv[])
std::cerr << std::unitbuf;

// You can use print statements as follows for debugging, they'll be visible when running tests.
std::cout << "Logs from your program will appear here!\n";
std::cerr << "Logs from your program will appear here!\n";

// Uncomment this block to pass the first stage
//
Expand Down
2 changes: 1 addition & 1 deletion starter_templates/csharp/code/src/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
}

// You can use print statements as follows for debugging, they'll be visible when running tests.
Console.WriteLine("Logs from your program will appear here!");
Console.Error.WriteLine("Logs from your program will appear here!");

string command = args[0];

Expand Down
2 changes: 1 addition & 1 deletion starter_templates/go/code/cmd/mygit/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
// Usage: your_program.sh <command> <arg1> <arg2> ...
func main() {
// You can use print statements as follows for debugging, they'll be visible when running tests.
fmt.Println("Logs from your program will appear here!")
fmt.Fprintf(os.Stderr, "Logs from your program will appear here!\n")

if len(os.Args) < 2 {
fmt.Fprintf(os.Stderr, "usage: mygit <command> [<args>...]\n")
Expand Down
2 changes: 1 addition & 1 deletion starter_templates/haskell/code/app/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import System.IO (IOMode (WriteMode), hPutStrLn, withFile)
main :: IO ()
main = do
-- You can use print statements as follows for debugging, they'll be visible when running tests.
putStrLn "Logs from your program will appear here"
hPutStrLn stderr "Logs from your program will appear here"

-- Uncomment this block to pass first stage
-- let createParents = True
Expand Down
2 changes: 1 addition & 1 deletion starter_templates/java/code/src/main/java/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
public class Main {
public static void main(String[] args){
// You can use print statements as follows for debugging, they'll be visible when running tests.
System.out.println("Logs from your program will appear here!");
System.err.println("Logs from your program will appear here!");

// Uncomment this block to pass the first stage
//
Expand Down
2 changes: 1 addition & 1 deletion starter_templates/javascript/code/app/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const fs = require("fs");
const path = require("path");

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

// Uncomment this block to pass the first stage
// const command = process.argv[2];
Expand Down
2 changes: 1 addition & 1 deletion starter_templates/python/code/app/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

def main():
# You can use print statements as follows for debugging, they'll be visible when running tests.
print("Logs from your program will appear here!")
print("Logs from your program will appear here!", file=sys.stderr)

# Uncomment this block to pass the first stage
#
Expand Down
2 changes: 1 addition & 1 deletion starter_templates/ruby/code/app/main.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# You can use print statements as follows for debugging, they'll be visible when running tests.
puts "Logs from your program will appear here!"
$stderr.puts "Logs from your program will appear here!"

# Uncomment this block to pass the first stage
#
Expand Down
2 changes: 1 addition & 1 deletion starter_templates/rust/code/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use std::fs;

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

// Uncomment this block to pass the first stage
// let args: Vec<String> = env::args().collect();
Expand Down
2 changes: 1 addition & 1 deletion starter_templates/typescript/code/app/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ enum Commands {
switch (command) {
case Commands.Init:
// You can use print statements as follows for debugging, they'll be visible when running tests.
console.log("Logs from your program will appear here!");
console.error("Logs from your program will appear here!");

// Uncomment this block to pass the first stage
// fs.mkdirSync(".git", { recursive: true });
Expand Down
2 changes: 1 addition & 1 deletion starter_templates/zig/code/src/main.zig
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ pub fn main() !void {
const command: []const u8 = args[1];

// You can use print statements as follows for debugging, they'll be visible when running tests.
try stdout.print("Logs from your program will appear here\n", .{});
std.debug.print("Logs from your program will appear here!\n", .{});

if (std.mem.eql(u8, command, "init")) {
// Uncomment this block to pass the first stage
Expand Down

0 comments on commit 7819e06

Please sign in to comment.