1
0
mirror of https://github.com/armink/EasyLogger.git synced 2025-01-31 21:42:53 +08:00

[demo] Update the windows demo and support the new file plugin.

This commit is contained in:
armink 2020-06-12 23:53:38 +08:00
parent 29bc4e5ee5
commit b67a5257c2
6 changed files with 127 additions and 3 deletions

View File

@ -31,6 +31,10 @@
/* enable log output. default open this macro */
#define ELOG_OUTPUT_ENABLE
/* enable log write file. default open this macro */
#define ELOG_FILE_ENABLE
/* enable flush file cache. default open this macro */
#define ELOG_FILE_FLUSH_CAHCE_ENABLE
/* setting static output log level */
#define ELOG_OUTPUT_LVL ELOG_LVL_VERBOSE
/* enable assert check */

View File

@ -0,0 +1,41 @@
/*
* This file is part of the EasyLogger Library.
*
* Copyright (c) 2015-2019, Qintl, <qintl_linux@163.com>
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* 'Software'), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
* Function: It is the configure head file for this flash log plugin.
* Created on: 2019-01-05
*/
#ifndef _ELOG_FILE_CFG_H_
#define _ELOG_FILE_CFG_H_
/* EasyLogger file log plugin's using file name */
#define ELOG_FILE_NAME "logs/elog_file.log"
/* EasyLogger file log plugin's using file max size */
#define ELOG_FILE_MAX_SIZE (1 * 1024 * 1024)
/* EasyLogger file log plugin's using max rotate file count */
#define ELOG_FILE_MAX_ROTATE 10
#endif /* _ELOG_FILE_CFG_H_ */

View File

@ -0,0 +1,65 @@
/*
* This file is part of the EasyLogger Library.
*
* Copyright (c) 2015-2019, Qintl, <qintl_linux@163.com>
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* 'Software'), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
* Function: Portable interface for EasyLogger's file log pulgin.
* Created on: 2019-01-05
*/
#include <elog_file.h>
/**
* EasyLogger flile log pulgin port initialize
*
* @return result
*/
ElogErrCode elog_file_port_init(void) {
ElogErrCode result = ELOG_NO_ERR;
/* do noting, using elog_port.c's locker only */
return result;
}
/**
* file log lock
*/
void elog_file_port_lock(void)
{
/* do noting, using elog_port.c's locker only */
}
/**
* file log unlock
*/
void elog_file_port_unlock(void)
{
/* do noting, using elog_port.c's locker only */
}
/**
* file log deinit
*/
void elog_file_port_deinit(void)
{
/* do noting, using elog_port.c's locker only */
}

View File

@ -31,6 +31,10 @@
#include <pthread.h>
#include <windows.h>
#ifdef ELOG_FILE_ENABLE
#include <elog_file.h>
#endif
static pthread_mutex_t output_lock;
/**
@ -43,6 +47,10 @@ ElogErrCode elog_port_init(void) {
pthread_mutex_init(&output_lock, NULL);
#ifdef ELOG_FILE_ENABLE
elog_file_init();
#endif
return result;
}
@ -55,6 +63,10 @@ ElogErrCode elog_port_init(void) {
void elog_port_output(const char *log, size_t size) {
/* output to terminal */
printf("%.*s", size, log);
#ifdef ELOG_FILE_ENABLE
/* write the file */
elog_file_write(log, size);
#endif
}
/**

View File

@ -80,6 +80,6 @@ void test_elog(void) {
log_d("Hello EasyLogger!");
log_v("Hello EasyLogger!");
// elog_raw("Hello EasyLogger!");
Sleep(5000);
Sleep(1000);
}
}

View File

@ -1,5 +1,7 @@
gcc -I "easylogger\inc" -I "..\..\..\easylogger\inc" -O0 -g3 -Wall -c "..\..\..\easylogger\src\elog.c" -o "out\elog.o"
gcc -I "easylogger\inc" -I "..\..\..\easylogger\inc" -O0 -g3 -Wall -c "easylogger\port\elog_port.c" -o "out\elog_port.o"
gcc -I "easylogger\inc" -I "..\..\..\easylogger\inc" -I "..\..\..\easylogger\plugins\file" -O0 -g3 -Wall -c "easylogger\port\elog_port.c" -o "out\elog_port.o"
gcc -I "easylogger\inc" -I "..\..\..\easylogger\inc" -O0 -g3 -Wall -c "..\..\..\easylogger\src\elog_utils.c" -o "out\elog_utils.o"
gcc -I "easylogger\inc" -I "..\..\..\easylogger\inc" -O0 -g3 -Wall -c "..\..\..\easylogger\plugins\file\elog_file.c" -o "out\elog_file.o"
gcc -I "easylogger\inc" -I "..\..\..\easylogger\inc" -I "..\..\..\easylogger\plugins\file" -O0 -g3 -Wall -c "..\..\..\easylogger\plugins\file\elog_file_port.c" -o "out\elog_file_port.o"
gcc -I "easylogger\inc" -I "..\..\..\easylogger\inc" -O0 -g3 -Wall -c "main.c" -o "out\main.o"
gcc -o out\EasyLoggerWinDemo.exe "out\main.o" "out\elog_utils.o" "out\elog.o" "out\elog_port.o" -lpthread
gcc -o out\EasyLoggerWinDemo.exe "out\main.o" "out\elog_utils.o" "out\elog.o" "out\elog_port.o" "out\elog_file.o" "out\elog_file_port.o" -lpthread