1 /*---------------------------------------------------------------------------*
2   Project:  Revolution oslog Demo
3   File:     oslogdemo.c
4 
5   Copyright 2008-2009 Nintendo. All rights reserved.
6 
7   These coded instructions, statements, and computer programs contain
8   proprietary information of Nintendo of America Inc. and/or Nintendo
9   Company Ltd., and are protected by Federal copyright law. They may
10   not be disclosed to third parties or copied or duplicated in any form,
11   in whole or in part, without the prior written consent of Nintendo.
12  *---------------------------------------------------------------------------*/
13 
14 #include <revolution.h>
15 #include <revolution/os/OSLog.h>
16 
17 #define NUM_TEST 4
18 
19 void stubOSVReport(const char* msg, ... );
stubOSVReport(const char * msg,...)20 void stubOSVReport(const char* msg, ... )
21 {
22 	va_list marker;
23     va_start(marker, msg);
24     OSVReport(msg, marker);
25     va_end(marker);
26 }
27 
main()28 void main()
29 {
30     int i;
31     s32 ret;
32 
33     // ------------------------------------------------- //
34     // 1. Write to NAND
35     // ------------------------------------------------- //
36 
37     // Set output destination to NAND
38     ret = OSReportDestination( OS_REPORT_NAND );
39     if(ret != OSLOG_RESULT_OK)
40     {
41         OSReport("Can not set destination of OSReport.\n"); // If output destination was not switched appropriately
42     }
43 
44     // Actually perform OSReport output
45     for(i=0; i<NUM_TEST; i++)
46     {
47         OSReport("%d: OSReport NAND Write\n", i);
48     }
49 
50     // Actually perform OSVReport output
51     for(i=0; i<NUM_TEST; i++)
52     {
53         stubOSVReport("%d: OSVReport NAND Write\n", i);
54     }
55 
56     // Actually write to NAND
57     ret = OSReportFlush();
58     if(ret != OSLOG_RESULT_OK)
59     {
60         OSReport("Can not write OSReport log to NAND.\n"); // Failed to write to NAND
61     }
62 
63     // ------------------------------------------------- //
64     // 2. Write to serial
65     // ------------------------------------------------- //
66 
67     // Set output destination to SERIAL
68     ret = OSReportDestination( OS_REPORT_SERIAL );
69     if(ret != OSLOG_RESULT_OK)
70     {
71         OSReport("Can not set destination of OSReport.\n");
72     }
73 
74     // Actually perform OSReport output
75     for(i=0; i<NUM_TEST; i++)
76     {
77         OSReport("%d: OSReport SERIAL Write\n", i); // Failed in writing to SERIAL
78     }
79 
80     // Actually perform OSVReport output
81     for(i=0; i<NUM_TEST; i++)
82     {
83         stubOSVReport("%d: OSVReport SERIAL Write\n", i); // Failed in writing to SERIAL
84     }
85 
86     // ------------------------------------------------- //
87     // 3. Write to both NAND and SERIAL
88     // ------------------------------------------------- //
89 
90     // Set output destination to output simultaneously to SERIAL and NAND
91     ret = OSReportDestination( OS_REPORT_NAND | OS_REPORT_SERIAL );
92     if(ret != OSLOG_RESULT_OK)
93     {
94         OSReport("Can not set destination of OSReport.\n"); // If output destination was not switched appropriately
95     }
96 
97     // Actually perform OSReport output
98     for(i=0; i<NUM_TEST; i++)
99     {
100         OSReport("%d: OSReport SERIAL and NAND Write\n", i);
101     }
102 
103     // Actually perform OSVReport output
104     for(i=0; i<NUM_TEST; i++)
105     {
106         OSReport("%d: OSVReport SERIAL and NAND Write\n", i);
107     }
108 
109     // Actually write to NAND
110     ret = OSReportFlush();
111     if(ret != OSLOG_RESULT_OK)
112     {
113         OSReport("Can not write OSReport log to NAND.\n"); // Failed to write to NAND
114     }
115 }
116 
117