Changeset 98 in libcf
- Timestamp:
- 05/28/13 17:35:32 (11 years ago)
- Location:
- trunk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/cf_log.h
r66 r98 28 28 #define CF_LOG_BUFFER_NO 0 29 29 30 /** 31 * 로그 레벨 사용 안함 32 * 33 * @see CF_Log_SetLevel 34 */ 35 #define CF_LOG_NO_LEVEL -1 36 30 37 #ifdef __cplusplus 31 38 extern "C" { … … 47 54 48 55 CF_EXPORT int 49 CF_Log_SetMT (const int mapid,50 const CF_BOOL flag);51 52 CF_EXPORT int53 56 CF_Log_Write (const int mapid, 54 57 const char * prefix, … … 58 61 CF_Log_Flush (const int mapid); 59 62 63 CF_EXPORT int 64 CF_Log_SetMT (const int mapid, 65 const CF_BOOL flag); 66 67 CF_EXPORT int 68 CF_Log_SetLevel (const int level); 69 60 70 #ifdef __cplusplus 61 71 } -
trunk/src/cf_log.c
r93 r98 88 88 CF_Log_Ctx * ctxPool; 89 89 int ctxSize; 90 int level; 90 91 } S_CF_LOG_ARRAY, CF_LOG_ARRAY; 91 92 … … 448 449 * @param ctx 로그 컨텍스트 449 450 * 450 * @remark 반드시 먼저 초기화 해야하며, 초기화 시에 주어진 번호보다 작은 아이디 넘버를 사용 해야 함451 * @remark 반드시 먼저 초기화 해야하며, 초기화 시에 주어진 번호보다 작은 아이디 넘버를 사용 451 452 * 452 453 * @see CF_LOG_OPEN, CF_Log_CreateCtx … … 531 532 return CF_ERROR_LOG_INITIALIZE; 532 533 gLogArray.ctxSize = logPool; 534 gLogArray.level = CF_LOG_NO_LEVEL; 533 535 } 534 536 … … 564 566 * @return 성공 시, CF_OK; 실패 시, 오류 코드 565 567 * 566 * @param mapid 568 * @param mapid 로그의 아이디 넘버 567 569 * @param path 로그 파일 경로 568 570 * @param memsize 로그 버퍼 크기 … … 603 605 604 606 /** 607 * 로그 버퍼의 데이터를 즉시 로그 파일에 쓰기 608 * 609 * @return 성공 시, CF_OK; 실패 시, 오류 코드 610 * 611 * @param mapid 로그의 아이디 넘버 612 */ 613 int 614 CF_Log_Flush (const int mapid) 615 { 616 int result = 0; 617 CF_Log_Ctx ctx = NULL; 618 619 result = CF_Log_GetMappedCtx (mapid, &ctx); 620 if (result < 0) 621 return result; 622 623 result = CF_Log_FlushCtx (ctx); 624 625 return result; 626 } 627 628 /** 629 * 로그 컨텍스트에 멀티쓰레드 모드 설정 630 * 631 * @return 성공 시, CF_OK; 실패 시, 오류 코드 632 * 633 * @param mapid 로그의 아이디 넘버 634 * @param flag 설정/해제 bool 플래그 635 * 636 * @see CF_BOOL 637 */ 638 int 639 CF_Log_SetMT (const int mapid, 640 const CF_BOOL flag) 641 { 642 int result = 0; 643 CF_Log_Ctx ctx = NULL; 644 645 result = CF_Log_GetMappedCtx (mapid, &ctx); 646 if (result < 0) 647 return result; 648 649 result = (flag) ? CF_Log_SetMultiThread (ctx) : 650 CF_Log_UnsetMultiThread (ctx); 651 652 return result; 653 } 654 655 /** 656 * 현재 설정된 로그 레벨을 가져옴 657 * 658 * @return 성공 시, CF_OK; 실패 시, 오류 코드 659 * 660 * @param mapid 로그의 아이디 넘버 661 * @param flag 설정/해제 bool 플래그 662 */ 663 static int 664 CF_Log_GetLevel (void) 665 { 666 return (gLogArray.level == CF_LOG_NO_LEVEL) ? gLogArray.ctxSize 667 : gLogArray.level; 668 } 669 670 /** 671 * 로그 레벨을 설정 672 * 지정된 로그 레벨 이하의 아이디 넘버만 로그로 기록하도록 설정 673 * 674 * @return 성공 시, CF_OK; 실패 시, 오류 코드 675 * 676 * @param mapid 로그의 아이디 넘버 677 * @param flag 설정/해제 bool 플래그 678 * 679 * @see CF_LOG_NO_LEVEL 680 */ 681 int 682 CF_Log_SetLevel (const int level) 683 { 684 gLogArray.level = level; 685 686 return CF_OK; 687 } 688 689 /** 605 690 * 로그 쓰기 606 691 * … … 621 706 va_list valist; 622 707 708 result = CF_Log_GetLevel (); 709 if (result < mapid) 710 return CF_OK; 711 623 712 result = CF_Log_GetMappedCtx (mapid, &ctx); 624 713 if (result < 0) … … 631 720 return result; 632 721 } 633 634 /**635 * 로그 버퍼의 데이터를 즉시 로그 파일에 쓰기636 *637 * @return 성공 시, CF_OK; 실패 시, 오류 코드638 *639 * @param mapid 로그의 아이디 넘버640 */641 int642 CF_Log_Flush (const int mapid)643 {644 int result = 0;645 CF_Log_Ctx ctx = NULL;646 647 result = CF_Log_GetMappedCtx (mapid, &ctx);648 if (result < 0)649 return result;650 651 result = CF_Log_FlushCtx (ctx);652 653 return result;654 }655 656 /**657 * 로그 컨텍스트에 멀티쓰레드 모드 설정658 *659 * @return 성공 시, CF_OK; 실패 시, 오류 코드660 *661 * @param mapid 로그의 아이디 넘버662 * @param flag 설정/해제 bool 플래그663 *664 * @see CF_BOOL665 */666 int667 CF_Log_SetMT (const int mapid,668 const CF_BOOL flag)669 {670 int result = 0;671 CF_Log_Ctx ctx = NULL;672 673 result = CF_Log_GetMappedCtx (mapid, &ctx);674 if (result < 0)675 return result;676 677 if (flag)678 result = CF_Log_SetMultiThread (ctx);679 else680 result = CF_Log_UnsetMultiThread (ctx);681 682 return result;683 } -
trunk/test/log.c
r66 r98 26 26 } 27 27 28 if (CF_Log_SetLevel (5) < 0) 29 fprintf (stderr, "failed to set log level\n"); 30 28 31 for (i = 0 ; i < 10 ; i++) 29 32 { -
trunk/test/test.c
r96 r98 119 119 } 120 120 121 if (CF_Log_SetLevel (5) < 0) 122 fprintf (stderr, "failed to set log level\n"); 123 121 124 for (i = 0 ; i < 10 ; i++) 122 125 {
Note:
See TracChangeset
for help on using the changeset viewer.