mrkmarron / logpp Goto Github PK
View Code? Open in Web Editor NEWAn experimental next generation logging framework for JavaScript and fluent.
License: MIT License
An experimental next generation logging framework for JavaScript and fluent.
License: MIT License
Hi, I tried to save a json into a file. First I did this:
const wstream = require("fs").createWriteStream("./scratchlog2.txt");
const logpp = require("logpp")("basic", { prefix: false, flushCount: 0, bufferSizeLimit: 0 , flushTarget: "stream", stream: wstream });
logpp.addFormat("Basic_Hello", "Hello World!!!");
logpp.info(logpp.$Basic_Hello);
And I could write on the file, but with this
const wstream = require("fs").createWriteStream("./scratchlog2.txt");
const logpp = require("logpp")("basic", { prefix: false, flushCount: 0, bufferSizeLimit: 0 , flushTarget: "stream", stream: wstream });
log.addFormat("Json", {kind: "start", time: "#wallclock", value: "%j"});
log.info(log.$Json, [1, 2]);
Nothing was written. Regards.
Great work on this!
On Node 10.3.0 I'm getting:
In file included from ../nsrc/nlogger.cc:4:
../nsrc/environment.h:35:9: warning: field 'm_formats' will be initialized after field 'm_msgTimeLimit' [-Wreorder]
m_formats(),
^
../nsrc/environment.h:63:19: warning: comparison of integers of different signs: 'int64_t' (aka 'long long') and 'std::__1::vector<std::__1::shared_ptr<MsgFormat>, std::__1::allocator<std::__1::shared_ptr<MsgFormat> > >::size_type' (aka 'unsigned long') [-Wsign-compare]
if (fmtId == this->m_formats.size())
~~~~~ ^ ~~~~~~~~~~~~~~~~~~~~~~
In file included from ../nsrc/nlogger.cc:6:
../nsrc/formatter.h:67:9: error: use of undeclared identifier 'memcpy_s'
memcpy_s(this->m_buff + this->m_curr, str.length(), str.c_str(), str.length());
^
../nsrc/formatter.h:134:25: error: use of undeclared identifier 'sprintf_s'
this->m_curr += sprintf_s(this->m_buff + this->m_curr, 32, "%I64i", val);
^
../nsrc/formatter.h:139:18: error: no member named 'isnan' in namespace 'std'
if (std::isnan(val))
~~~~~^
../nsrc/formatter.h:151:18: error: use of undeclared identifier 'floor'
else if (floor(val) == val)
^
../nsrc/formatter.h:154:29: error: use of undeclared identifier 'sprintf_s'
this->m_curr += sprintf_s(this->m_buff + this->m_curr, 32, "%I64i", static_cast<int64_t>(val));
^
../nsrc/formatter.h:159:29: error: use of undeclared identifier 'sprintf_s'
this->m_curr += sprintf_s(this->m_buff + this->m_curr, 32, "%f", val);
^
../nsrc/formatter.h:188:29: error: use of undeclared identifier 'sprintf_s'
this->m_curr += sprintf_s(this->m_buff + this->m_curr, 32, ".%03dZ", msval);
^
../nsrc/formatter.h:59:9: error: use of undeclared identifier 'memcpy_s'
memcpy_s(this->m_buff + this->m_curr, N, &str, N);
^
../nsrc/formatter.h:141:19: note: in instantiation of function template specialization 'Formatter::emitLiteralString<5>' requested here
this->emitLiteralString("null");
^
../nsrc/formatter.h:59:9: error: use of undeclared identifier 'memcpy_s'
memcpy_s(this->m_buff + this->m_curr, N, &str, N);
^
../nsrc/formatter.h:207:19: note: in instantiation of function template specialization 'Formatter::emitLiteralString<14>' requested here
this->emitLiteralString("\"<BadFormat>\"");
^
../nsrc/formatter.h:59:9: error: use of undeclared identifier 'memcpy_s'
memcpy_s(this->m_buff + this->m_curr, N, &str, N);
^
../nsrc/formatter.h:210:19: note: in instantiation of function template specialization 'Formatter::emitLiteralString<8>' requested here
this->emitLiteralString("\"{...}\"");
^
../nsrc/formatter.h:59:9: error: use of undeclared identifier 'memcpy_s'
memcpy_s(this->m_buff + this->m_curr, N, &str, N);
^
../nsrc/formatter.h:213:19: note: in instantiation of function template specialization 'Formatter::emitLiteralString<16>' requested here
this->emitLiteralString("\"$rest$\": \"...\"");
^
../nsrc/formatter.h:59:9: error: use of undeclared identifier 'memcpy_s'
memcpy_s(this->m_buff + this->m_curr, N, &str, N);
^
../nsrc/formatter.h:219:19: note: in instantiation of function template specialization 'Formatter::emitLiteralString<6>' requested here
this->emitLiteralString("\"...\"");
^
../nsrc/formatter.h:59:9: error: use of undeclared identifier 'memcpy_s'
memcpy_s(this->m_buff + this->m_curr, N, &str, N);
^
../nsrc/formatter.h:222:19: note: in instantiation of function template specialization 'Formatter::emitLiteralString<10>' requested here
this->emitLiteralString("\"<Cycle>\"");
^
../nsrc/formatter.h:59:9: error: use of undeclared identifier 'memcpy_s'
memcpy_s(this->m_buff + this->m_curr, N, &str, N);
^
../nsrc/processingblock.h:96:32: note: in instantiation of function template specialization 'Formatter::emitLiteralString<3>' requested here
formatter->emitLiteralString(", ");
^
In file included from ../nsrc/nlogger.cc:6:
../nsrc/formatter.h:59:9: error: use of undeclared identifier 'memcpy_s'
memcpy_s(this->m_buff + this->m_curr, N, &str, N);
^
../nsrc/processingblock.h:183:24: note: in instantiation of function template specialization 'Formatter::emitLiteralString<4>' requested here
formatter->emitLiteralString(" @ ");
^
In file included from ../nsrc/nlogger.cc:6:
../nsrc/formatter.h:59:9: error: use of undeclared identifier 'memcpy_s'
memcpy_s(this->m_buff + this->m_curr, N, &str, N);
^
../nsrc/processingblock.h:187:24: note: in instantiation of function template specialization 'Formatter::emitLiteralString<7>' requested here
formatter->emitLiteralString(" from ");
^
In file included from ../nsrc/nlogger.cc:5:
../nsrc/format.h:32:19: warning: private field 'm_formatId' is not used [-Wunused-private-field]
const int64_t m_formatId; //a unique identifier for the format
^
3 warnings and 16 errors generated.
make: *** [Release/obj.target/nlogger/nsrc/nlogger.o] Error 1
i am trying to build a wrapper around this module so I don't need to setup common options every time i need it in a new service.
But looking at the code, the log only works if required from main entry file. if not, all functions are NOP. this is a limitation in my point of view.
Can you help me out, if i am missing something to make it work when requiring it from another files other than the main one? messing with the setLoggingLevel
and alike, does not seem to make effect.
Really appreciate your help
As a todo in the code there is a note about needing to format non-ascii characters. So, right now there will be formatting errors if these chars appear.
i followed the normal setup but no console is showing in express app.
const log = require("logpp")("myapp");
log.info("Hello %s!!!", "printf");
There is an issue with canceling the async formatting task (to do blocking sequential write) on exit. It looks like we need to do some work with the AsyncWorker logic in the native code.
Does Log++ provide a native (i.e. C/C++) API in addition to the JS API for applications to use for logging? Or would it be feasible to add such an API? I'm asking because I am maintaining a Node.js module which has a native add-on, and I have not yet been able to find a logging framework that would allow me to generate log messages both from the JS as well as the C++ parts of the module and write them to a single log stream, with a single set of logging formats, levels, etc. I was hopeful when I saw that Log++ actually does the logging in a native add-on, but it seems there is no native API exposed.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.