Coder Social home page Coder Social logo

logpp's People

Contributors

mrkmarron avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

logpp's Issues

Problem to write json on a file

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.

not building on Mac OS X

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

log only works if required from main file

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

not showing logs in express js

i followed the normal setup but no console is showing in express app.
const log = require("logpp")("myapp");
log.info("Hello %s!!!", "printf");

Error on exit with async format in progress.

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.

Question: Native API for Logging in other Native Add-ons

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.