src/platform/python/log.c (view raw)
1/* Copyright (c) 2013-2016 Jeffrey Pfau
2 *
3 * This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6#include "log.h"
7
8static void _pyLogShim(struct mLogger* logger, int category, enum mLogLevel level, const char* format, va_list args) {
9 struct mLoggerPy* pylogger = (struct mLoggerPy*) logger;
10 char message[256] = {0};
11 vsnprintf(message, sizeof(message) - 1, format, args);
12 _pyLog(pylogger, category, level, message);
13}
14
15struct mLogger* mLoggerPythonCreate(void* pyobj) {
16 struct mLoggerPy* logger = malloc(sizeof(*logger));
17 logger->d.log = _pyLogShim;
18 logger->d.filter = NULL;
19 logger->pyobj = pyobj;
20 return &logger->d;
21}