77import cloud .stackit .sdk .iaas .model .*;
88import java .io .IOException ;
99import java .util .UUID ;
10+ import java .util .logging .Level ;
11+ import java .util .logging .Logger ;
1012import okhttp3 .OkHttpClient ;
1113
1214/*
2224 *
2325 * */
2426public class CustomHttpClientExample {
27+ private static final Logger LOGGER = Logger .getLogger (CustomHttpClientExample .class .getName ());
28+
2529 public static void main (String [] args ) throws IOException {
2630 // Credentials are read from the credentialsFile in `~/.stackit/credentials.json` or the env
2731 // STACKIT_SERVICE_ACCOUNT_KEY_PATH / STACKIT_SERVICE_ACCOUNT_KEY
@@ -37,17 +41,19 @@ public static void main(String[] args) throws IOException {
3741 // the id of your STACKIT project, read from env var for this example
3842 String projectIdString = System .getenv ("STACKIT_PROJECT_ID" );
3943 if (projectIdString == null || projectIdString .isEmpty ()) {
40- System . err . println ("Environment variable 'STACKIT_PROJECT_ID' not found." );
44+ LOGGER . severe ("Environment variable 'STACKIT_PROJECT_ID' not found." );
4145 return ;
4246 }
4347 UUID projectId = UUID .fromString (projectIdString );
4448
4549 try {
4650 /* list all servers */
4751 ServerListResponse servers = iaasApi .listServers (projectId , false , null );
48- System .out .println ("\n Available servers: " );
49- for (Server server : servers .getItems ()) {
50- System .out .println ("* " + server .getId () + " | " + server .getName ());
52+ if (LOGGER .isLoggable (Level .INFO )) {
53+ LOGGER .info ("\n Available servers: " );
54+ for (Server server : servers .getItems ()) {
55+ LOGGER .info ("* " + server .getId () + " | " + server .getName ());
56+ }
5157 }
5258 } catch (ApiException e ) {
5359 throw new RuntimeException (e );
0 commit comments