Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DB logger sample #4759

Merged
merged 17 commits into from
Nov 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
6b01528
sample(DBLogger): New sample to demonstrate DB logging to a file. (#4…
matejk Nov 6, 2024
e4d795d
sample(DBLogger): Create messages via SQL logger in a thread (#4750)
matejk Nov 6, 2024
93230d6
sample(DBLogger): Save messages from SQL files to an SQL database (wo…
matejk Nov 6, 2024
2f7e38f
chore(Makefile): Data samples depend on PocoUtil (#4750)
matejk Nov 7, 2024
3a34c67
sample(DBLogger): Refactored DBLogger with std::filesystem::directory…
matejk Nov 8, 2024
75faa3c
sample(DBLogger): Add missing include <condition_variable>
matejk Nov 8, 2024
57413e9
sample(DBLogger): Extracted log scanning and inserting functionality …
matejk Nov 9, 2024
17ca42a
sample(DBLogger): Create new logging table only when using demo messa…
matejk Nov 11, 2024
9159327
feat(DBLogger): VS projects
aleks-f Nov 11, 2024
a7744fe
sample(DBLogger): Acquire options from configuration file.
matejk Nov 11, 2024
be5272c
feat(DBLogger): regenerate VS projects (progen file change)
aleks-f Nov 11, 2024
577c0a6
sample(DBLogger): Add example DBLogger.properties file.
matejk Nov 12, 2024
8cef3d9
sample(DBLogger): Process as much as possible when stopping processing.
matejk Nov 13, 2024
99e0ea9
sample(DBLogger): Meaningful defaults in properties file.
matejk Nov 13, 2024
94ebcfa
sample(DBLogger): Verify validity of database session on startup.
matejk Nov 13, 2024
04b3db1
sample(DBLogger): Configure demo SQL channel in properties file.
matejk Nov 14, 2024
d029667
chore(DBLogger): style and warnings
aleks-f Nov 18, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions Data/SQLite/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,6 @@ else()
POCO_SOURCES(SQLITE_SRCS sqlite3
src/sqlite3.c
)

POCO_HEADERS(SQLITE_SRCS sqlite3
src/sqlite3.h
)
endif()

# Version Resource
Expand Down
1 change: 1 addition & 0 deletions Data/samples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ add_subdirectory(RowFormatter)
add_subdirectory(Tuple)
add_subdirectory(TypeHandler)
add_subdirectory(WebNotifier)
add_subdirectory(DBLogger)
14 changes: 14 additions & 0 deletions Data/samples/DBLogger/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@

# Sources
file(GLOB SRCS_G "src/*.cpp")
POCO_SOURCES_AUTO(DBLOGGER_SRCS ${SRCS_G})

# Headers
file(GLOB_RECURSE HDRS_G "src/*.h")
POCO_HEADERS_AUTO(DBLOGGER_SRCS ${HDRS_G})

add_executable(DBLogger ${DBLOGGER_SRCS})

target_link_libraries(DBLogger PUBLIC Poco::Util Poco::DataSQLite)

add_custom_target(DBLogger-properties SOURCES DBLogger.properties)
11 changes: 11 additions & 0 deletions Data/samples/DBLogger/DBLogger.progen
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
vc.project.guid = ${vc.project.guidFromName}
vc.project.name = ${vc.project.baseName}
vc.project.target = ${vc.project.name}
vc.project.type = executable
vc.project.pocobase = ..\\..\\..
vc.project.platforms = Win32
vc.project.configurations = debug_shared, release_shared, debug_static_mt, release_static_mt, debug_static_md, release_static_md
vc.project.prototype = ${vc.project.name}_vs90.vcproj
vc.project.compiler.include = ..\\..\\..\\Foundation\\include;..\\..\\..\\JSON\\include;..\\..\\..\\XML\\include;..\\..\\..\\Util\\include;..\\..\\..\\Data\\include;..\\..\\..\\Data\\SQLParser;..\\Data\\SQLParser\\src;..\\..\\..\\Data\\SQLite\\include
vc.project.compiler.additionalOptions = /Zc:__cplusplus
vc.project.linker.dependencies = iphlpapi.lib
67 changes: 67 additions & 0 deletions Data/samples/DBLogger/DBLogger.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@

#
# Database inserter (destination)
#

#
# Destination database parameters:
#
# (Mandatory) Database connector (for example sqlite)
#
DBLogger.connector = sqlite

#
# (Mandatory) Database connection string (connector specific)
#
DBLogger.constring = demo-logs.db3

#
# (Optional) Number of workers to insert logs into the database in parallel (default = 2)
#
# DBLogger.workers = 2

# ----------------------------------------------------------------

#
# (Optional) Create demo SQL messages for testing purposes (default = false)
#
DBLogger.demo = true

logging.loggers.root.channel = console
logging.loggers.root.level = information

logging.channels.console.class = ColorConsoleChannel
logging.channels.console.pattern = %L%Y-%m-%d %H:%M:%S.%i [%p] : %t

#
# SQL logger to create demo messages
# NOTE: Do not rename the logger.
#

logging.loggers.sqldemo.channel = sql
logging.loggers.sqldemo.name = SQLDemo
logging.loggers.sqldemo.level = debug

logging.channels.sql.class = SQLChannel
logging.channels.sql.name = DBLogger

#
# (Mandatory) Directory to scan for .sql files
#
logging.channels.sql.directory = .

#
# NOTE: Do not configure database to create SQL logger files
#
# logging.channels.sql.connector = SQLite
# logging.channels.sql.connect = DBLogger.db3

logging.channels.sql.timeout = 3000
logging.channels.sql.minBatch = 5
logging.channels.sql.maxBatch = 1000
logging.channels.sql.bulk = true
logging.channels.sql.table = T_LOG

logging.channels.sql.throw = false
logging.channels.sql.file = ${application.baseName}.sql

663 changes: 663 additions & 0 deletions Data/samples/DBLogger/DBLogger_vs160.vcxproj

Large diffs are not rendered by default.

17 changes: 17 additions & 0 deletions Data/samples/DBLogger/DBLogger_vs160.vcxproj.filters
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Header Files">
<UniqueIdentifier>{8747f452-7c1b-44d2-b0e5-1681f3dab78e}</UniqueIdentifier>
</Filter>
<Filter Include="Source Files">
<UniqueIdentifier>{f73ed930-0047-402d-8e77-3b9b9ddbc3a7}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="src\SQLLogInserter.cpp" />
<ClCompile Include="src\DBLogger.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
</Project>
978 changes: 978 additions & 0 deletions Data/samples/DBLogger/DBLogger_vs170.vcxproj

Large diffs are not rendered by default.

17 changes: 17 additions & 0 deletions Data/samples/DBLogger/DBLogger_vs170.vcxproj.filters
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Header Files">
<UniqueIdentifier>{b2b53da4-c45b-4734-9096-6c64453817a6}</UniqueIdentifier>
</Filter>
<Filter Include="Source Files">
<UniqueIdentifier>{654b0a83-74d5-4a84-b813-6493ce240b90}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="src\SQLLogInserter.cpp" />
<ClCompile Include="src\DBLogger.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
</Project>
Loading
Loading