donglie1994 2015-04-09 16:35
浏览 47

CGO和日志记录

I'm about to adopt an enhaced logging library in a Go codebase, I've reduced my scope to logxi and log15. Even though they seem quite new, I like the logfmt enforcement offered by them, although each has its advantages and disadvantages. Anyway, even bringing the simpler standard logging facility to the question, an issue remains.

I'm mixing Go and C++ a lot (through C bridges and CGO). I'm facing the issue of whether I should make Go callbacks for logging from C++ or logging straight from C++, which would make me miss the library pattern adopted in Go. In any case, let's say I'm talking about logging to stdout, I'm still unsure how to proceed with a best option about having synchronized output, since it's both Go and C land and I'll have some threads looping in C while some goroutines running on its own. By adopting the callbacks this may not be an issue, but it may be expensive... Also wrapping a logging facility for C is problematic since they generally provide a variadic API in Go.

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
    • ¥15 谁有desed数据集呀
    • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100
    • ¥15 关于#hadoop#的问题
    • ¥15 (标签-Python|关键词-socket)
    • ¥15 keil里为什么main.c定义的函数在it.c调用不了
    • ¥50 切换TabTip键盘的输入法
    • ¥15 可否在不同线程中调用封装数据库操作的类
    • ¥15 微带串馈天线阵列每个阵元宽度计算
    • ¥15 keil的map文件中Image component sizes各项意思