LingYun IoT Studio NB-IoT research project
Guo Wenxue
2018-11-20 bc9652bd9ad0c4ff9cf595ba68f702f44a92a3d6
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
/*********************************************************************************
 *      Copyright:  (C) 2012 Guo Wenxue <guowenxue@gmail.com>
 *                  All rights reserved.
 *
 *       Filename:  test_logger.c
 *    Description:  This is the linux logger system test code.
 *                 
 *        Version:  1.0.0(08/08/2012~)
 *         Author:  Guo Wenxue <guowenxue@gmail.com>
 *      ChangeLog:  1, Release initial version on "08/08/2012 06:51:40 PM"
 *                 
 ********************************************************************************/
 
#include <unistd.h>
#include <stdio.h>
#include <string.h>
#include <libgen.h>
#include "cp_logger.h"
 
 
/********************************************************************************
 *  Description:
 *   Input Args:
 *  Output Args:
 * Return Value:
 ********************************************************************************/
int main (int argc, char **argv)
{
    char    buf[30]="Hello World!\n";
    char    file[FILENAME_LEN];
 
    snprintf(file, FILENAME_LEN, "%s.log", basename(argv[0]) );
 
    //if (! cp_log_init(NULL, DBG_LOG_FILE, LOG_LEVEL_NRML, LOG_ROLLBACK_NONE) )
    //if (! cp_log_init(NULL, DEFAULT_LOGFILE, LOG_LEVEL_MAX, LOG_ROLLBACK_SIZE) )
    if(! cp_log_init(NULL, file, LOG_LEVEL_MAX, 12) || cp_log_open() )
        return 0;
 
 
    while(1)
    {
        log_info("1connection.\n");
        log_dbg("2connection.\n");
        log_nrml("3connection.\n");
        log_warn("4connection.\n");
        log_err("5connection.\n");
        log_fatal("6connection.\n");
 
        cp_log_dump(LOG_LEVEL_DEBUG, buf, 30);
 
        sleep(1);
    } 
    
    cp_log_term();
 
    return 0;
} /* ----- End of main() ----- */