Tips for getting Sandbox Output
Troubleshoot missing sandbox output during tests and learn how to generate debug output by using the target application (login, submit forms, etc.).
Sandbox Output
Sometimes you may need extra guidance while working through a lesson—especially in Break/Fix lessons. In these cases, you can add print/debug statements to your code to generate output in the Sandbox Output panel.
Output Examples
You can print output to the Sandbox Output panel using standard console/output functions for your language. This is useful for debugging, logging values, or verifying that your patched code is running as expected.
Below are examples of adding output to a simple login function in various languages.
C Output
Use printf (or similar functions) to produce output in the Sandbox Output panel.
#include <stdio.h>
int login(char* username, char* password) {
printf("Username: %s Password: %s\n", username, password);
return 0;
}C# / .NET Output
Use Console.WriteLine to produce output.
public static bool Login(string username, string password) {
Console.WriteLine($"username is {username}");
return false;
}
C++ Output
Use std::cout from the iostream library.
#include <iostream>
int login(char* username, char* password) {
std::cout << "Username: " << username << std::endl;
return 0;
}
Clojure Output
Use println or printf.
(defn login
[username password]
(printf "username is %s%n" username))
Go Output
Import the fmt package and use fmt.Println or fmt.Printf.
package main
import (
"fmt"
)
func login(username string, password string) (bool, error) {
fmt.Printf("username is %s\n", username)
return false, nil
}
Java Output
Use System.out.println or System.out.format.
public static boolean login(String username, String password) {
System.out.format("username is %s%n", username);
return false;
}
JavaScript Output
Use console.log.
exports.login = function(username, password) {
console.log(`username is ${username}`);
};
Kotlin Output
Use println.
fun login(username: String, password: String) {
println("username is $username")
}
Perl Output
Use print.
sub login {
my $username = $_[0];
print "username is $username\n";
}
PHP Output
Use echo.
function login($username, $password) {
echo 'username is ' . $username . "\n";
}
Python Output
Use print.
def login(username, password):
print("username is %s" % username)
Ruby Output
Use puts.
def self.login(username, password)
puts "username is %s" % username
end
Rust Output
Use the println! macro.
fn login(username: &str) {
println!("username is {username}");
}
Scala Output
Use println or printf.
def login(username: String, password: String): Boolean = {
printf("username is %s\n", username)
false
}
TypeScript Output
Use console.log.
exports.login = function(username: string, password: string): void {
console.log(`username is ${username}`);
};
Important Notes
-
You must interact with the target application to trigger output.
The required interaction depends on the lesson instructions (for example: log in, add a post, submit a form, etc.). - Example: If you added print/debug statements to the login authentication code, you’ll need to attempt a login in the web app to generate output and see it in the Sandbox Output panel.
-
Do not use the browser’s Developer Console for debug output.
The sandbox environment is meant to function like your development terminal/console, and your print statements should appear in the Sandbox Output panel instead.
Additional Considerations
We don’t show debug output during tests because it could reveal the test data. That would make it easy for learners to code specifically to the test results instead of building a solution that works generally.