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

Support logger without variable argument list #276

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

school510587
Copy link
Contributor

libchewing only accepts logger callback with variable argument list so far. However, it seems difficult to implement such callback using other language (eg. Python). This prevents direct access of log messages. Here, the PR implements a new built-in logger and a new API to remove the restriction.

  • It is cleaner to use vasprintf. However, vasprintf is not in C standard, and additional implementation will be needed to pass MSVC compilation.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.4%) to 90.212% when pulling 447b5fc on school510587:no_var_arg_list_logger into e469f5b on chewing:master.

@school510587 school510587 changed the title Support logger without variable argument listNo var arg list logger Support logger without variable argument list Jul 23, 2017
include/chewingio.h Outdated Show resolved Hide resolved
@school510587
Copy link
Contributor Author

school510587 commented Aug 9, 2017 via email

@jserv
Copy link
Member

jserv commented Aug 10, 2017

Cc. @czchen

The functionality of chewing_new2 is to provide another way to initialize Chewing engine. However, the function proposed by @school510587 is a different story, IMHO. I would suggest explicit naming.

@@ -545,7 +545,7 @@ CHEWING_API int chewing_get_phoneSeqLen(const ChewingContext *ctx);
CHEWING_API void chewing_set_logger(ChewingContext *ctx,
void (*logger) (void *data, int level, const char *fmt, ...), void *data);

CHEWING_API void chewing_set_logger2(ChewingContext *ctx,
CHEWING_API void chewing_set_logger_without_varglist(ChewingContext *ctx,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The suffix without_varglist is too long. I would expected to revise the use of API instead.

@coveralls
Copy link

coveralls commented Aug 11, 2017

Coverage Status

Coverage decreased (-0.4%) to 90.647% when pulling 016873b on school510587:no_var_arg_list_logger into 2ebcf13 on chewing:master.

@jserv
Copy link
Member

jserv commented Aug 11, 2017

How about using Swig to resolve the convention?
Reference: http://www.swig.org/Doc1.3/Varargs.html

@jserv
Copy link
Member

jserv commented Jul 20, 2019

Can you rebase for reviewing?

Data4NoVarArgListLogger keeps the real logger and data obtained from the
caller. Logger4NoVarArgList collects message properly and forwards it to
the real logger.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants