Comments (4)
Hello Balaji,
I think the answer depends on what you mean by a "truncated'' file. If you mean that the file has all bytes present and in order except for the very tail, then the decompressor should be able to interpret most of the log and then error out towards the very end.
If "truncated" means that bytes are missing in the middle (like say form a UDP packet drop), then you need to make sure that at least the NanoLog "dictionary" is sent in full to your remote location and that the log data present is aligned with the start a "BufferExtent". Once you have those two requirements, you should be able to hack the NanoLog Decoder accept the two separately and interpret the binary stream. Below is some information that may be helpful in your endeavor.
Good Luck.
Log File Structure and The Dictionary
How the log file looks and how you go about obtaining the dictionary are different depending on whether you’re working with Preprocessor NanoLog or C++17 NanoLog.
For Preprocessor NanoLog, the log file looks similar to Figure 4 in the NanoLog Paper. The log file contains a header, the dictionary for the entire application, and “Buffer Extents” which are groupings of log messages. The entire dictionary is built statically at compile-time and can be obtained by invoking the insertCheckpoint() function in runtime/Log.cc:118.
For C++17 NanoLog, the dictionary is built up piece-wise as the application runs. The format again resembles Figure 4 from the NanoLog Paper, except the “Dictionary” segment can appear in-between Buffer Extents, and each segment contains a fragment of the full dictionary. For your purposes, if you are missing dictionary entries, then you need to run logic similar to what’s found in runtime/RuntimeLogger.cc:393 to build it. And again, the dictionary is built up incrementally in C++17 NanoLog, so you will need to keep updating your remote dictionary as log messages are encountered during runtime. This is different from Preprocessor NanoLog which has the complete dictionary at application start.
Building Buffer Extents
To make sure log messages aren't cut randomly, I'd recommend you send only complete BufferExtents in UDP packets. The BufferExtents are built in this function. You can change the logic to build smaller extents that fit within the MTU of a UDP packet.
Of course, all this means you’ll also need to change the Decoder to accept the dictionary and BufferExtents separately, but it should be doable. Good Luck.
from nanolog.
Thanks that helps. Will check the same. I am using the preprocessor version were use python parser. Btw I see C++17 a must, is it possible to get it working with C++11 ?.
from nanolog.
The Preprocessor version of NanoLog will work with C++11.
The C++17 version of NanoLog, as the name implies, will need something newer.
from nanolog.
Thanks
root@localhost ~/nanolog/NanoLog/sample_preprocessor (master) $ git diff
diff --git a/NanoLogMakeFrag b/NanoLogMakeFrag
index 404103b..cdaa5cc 100644
--- a/NanoLogMakeFrag
+++ b/NanoLogMakeFrag
@@ -39,7 +39,7 @@ COMWARNS := -Wall -Wformat=2 -Wextra \
CWARNS := $(COMWARNS) -Wmissing-prototypes -Wmissing-declarations -Wshadow \
-Wbad-function-cast
CXXWARNS := $(COMWARNS) -Wno-non-template-friend -Woverloaded-virtual \
- -Wcast-qual -Wcast-align -Wconversion -Weffc++
+ -Wcast-qual -Wcast-align -Weffc++
.PHONY: all
all:
diff --git a/sample_preprocessor/GNUmakefile b/sample_preprocessor/GNUmakefile
index f8aaf2a..3b9633a 100644
--- a/sample_preprocessor/GNUmakefile
+++ b/sample_preprocessor/GNUmakefile
@@ -41,7 +41,7 @@ include $(NANOLOG_DIR)/NanoLogMakeFrag
# User Section
####
# -DNDEBUG and -O3 should always be passed for high performance
-CXXFLAGS= -std=c++17 -DNDEBUG -O3 -g
+CXXFLAGS= -std=c++11 -DNDEBUG -O3 -g
CXX=g++
I did above two changes and got it working..
from nanolog.
Related Issues (20)
- Any suggestion to improve NanoLog type safety? HOT 5
- Add a switch to enable log output to stdout.
- Add a macro switch for a more convenient uncompressed output.
- Try std::string_view instead
- Performance
- No conan or vcpkg integration
- Online decompressor HOT 1
- ability to file swap
- Having a background text file writer instead of the compressor with binary log writer
- Infinite Loop in Makefile Dependency Generation
- Write to multiple log files.
- Capability of file rolling
- Run into "Internal Error: Corrupted BufferExtend"
- Can I build a python wrap for nanolog?
- system level use of nanlog?
- windows support
- Memory leak in NanoLog?
- arm64 Support
- No updates since 3 years ago HOT 1
- is there a Rust equivalent of this package?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from nanolog.