source: libcf/trunk/test/log.c@ 35

Last change on this file since 35 was 35, checked in by cheese, 11 years ago

#1 separate example code and doxygen comment and fix logging push logic by vfire

File size: 858 bytes
Line 
1/**
2 * @file log.c
3 * @author myusgun <myusgun@gmail.com>
4 * @version 0.1
5 */
6#include "cf_log.h"
7#include <stdio.h>
8
9CF_Log_Ctx gLogCtx;
10
11int main (void)
12{
13 int i, j;
14 char logname[16] = {0x00,};
15
16 CF_Log_Initialize (10);
17
18 // with context
19 gLogCtx = CF_Log_CreateCtx ("log.txt", CF_LOG_BUFFER_DEFAULT);
20 if (gLogCtx == NULL)
21 fprintf (stderr, "create log ctx error\n");
22
23 for (i = 0 ; i < 10000 ; i++)
24 CF_Log_Write (gLogCtx, "LOG_TEST", "turn %d\n", i);
25
26 CF_Log_Write (gLogCtx, "prefix", "log test\n");
27
28 CF_Log_DestroyCtx (gLogCtx);
29
30 // with id number
31 for (i = 0 ; i < 10 ; i++)
32 {
33 sprintf (logname, "logid%d.txt", i);
34 CF_LOG_OPEN (i, logname, CF_LOG_BUFFER_NO);
35 }
36
37 for (i = 0 ; i < 10 ; i++)
38 {
39 for (j = 0 ; j < 10000 ; j++)
40 CF_LOG_WRITE (i, "LOG_ID_TEST", "turn %d\n", j);
41
42 CF_LOG_CLOSE (i);
43 }
44
45 CF_Log_Finalize ();
46
47 return 0;
48}
Note: See TracBrowser for help on using the repository browser.