LMMS
Loading...
Searching...
No Matches
logger.h
Go to the documentation of this file.
1/*
2 Copyright 2012-2016 David Robillard <http://drobilla.net>
3
4 Permission to use, copy, modify, and/or distribute this software for any
5 purpose with or without fee is hereby granted, provided that the above
6 copyright notice and this permission notice appear in all copies.
7
8 THIS SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11 ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14 OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15*/
16
27
28#ifndef LV2_ATOM_LOGGER_H
29#define LV2_ATOM_LOGGER_H
30
31#include <stdio.h>
32#include <string.h>
33
34#include "log.h"
35
36#ifdef __cplusplus
37extern "C" {
38#endif
39
51
58static inline void
60{
61 if (map) {
62 logger->Error = map->map(map->handle, LV2_LOG__Error);
63 logger->Note = map->map(map->handle, LV2_LOG__Note);
64 logger->Trace = map->map(map->handle, LV2_LOG__Trace);
65 logger->Warning = map->map(map->handle, LV2_LOG__Warning);
66 } else {
67 logger->Error = logger->Note = logger->Trace = logger->Warning = 0;
68 }
69}
70
78static inline void
80 LV2_URID_Map* map,
81 LV2_Log_Log* log)
82{
83 logger->log = log;
84 lv2_log_logger_set_map(logger, map);
85}
86
90LV2_LOG_FUNC(3, 0)
91static inline int
94 const char* fmt,
95 va_list args)
96{
97 if (logger && logger->log) {
98 return logger->log->vprintf(logger->log->handle, type, fmt, args);
99 } else {
100 return vfprintf(stderr, fmt, args);
101 }
102}
103
105LV2_LOG_FUNC(2, 3)
106static inline int
108{
109 va_list args;
110 va_start(args, fmt);
111 const int ret = lv2_log_vprintf(logger, logger->Error, fmt, args);
112 va_end(args);
113 return ret;
114}
115
117LV2_LOG_FUNC(2, 3)
118static inline int
120{
121 va_list args;
122 va_start(args, fmt);
123 const int ret = lv2_log_vprintf(logger, logger->Note, fmt, args);
124 va_end(args);
125 return ret;
126}
127
129LV2_LOG_FUNC(2, 3)
130static inline int
132{
133 va_list args;
134 va_start(args, fmt);
135 const int ret = lv2_log_vprintf(logger, logger->Trace, fmt, args);
136 va_end(args);
137 return ret;
138}
139
141LV2_LOG_FUNC(2, 3)
142static inline int
144{
145 va_list args;
146 va_start(args, fmt);
147 const int ret = lv2_log_vprintf(logger, logger->Warning, fmt, args);
148 va_end(args);
149 return ret;
150}
151
152#ifdef __cplusplus
153} /* extern "C" */
154#endif
155
156#endif /* LV2_LOG_LOGGER_H */
157
CAdPlugDatabase::CRecord::RecordType type
Definition adplugdb.cpp:93
#define LV2_LOG__Warning
http://lv2plug.in/ns/ext/log#Warning
Definition log.h:36
#define LV2_LOG__Error
http://lv2plug.in/ns/ext/log#Error
Definition log.h:33
#define LV2_LOG__Trace
http://lv2plug.in/ns/ext/log#Trace
Definition log.h:35
#define LV2_LOG__Note
http://lv2plug.in/ns/ext/log#Note
Definition log.h:34
static int lv2_log_error(LV2_Log_Logger *logger, const char *fmt,...)
Definition logger.h:107
static int lv2_log_note(LV2_Log_Logger *logger, const char *fmt,...)
Definition logger.h:119
static void lv2_log_logger_set_map(LV2_Log_Logger *logger, LV2_URID_Map *map)
Definition logger.h:59
static int lv2_log_vprintf(LV2_Log_Logger *logger, LV2_URID type, const char *fmt, va_list args)
Definition logger.h:92
static int lv2_log_trace(LV2_Log_Logger *logger, const char *fmt,...)
Definition logger.h:131
static int lv2_log_warning(LV2_Log_Logger *logger, const char *fmt,...)
Definition logger.h:143
static void lv2_log_logger_init(LV2_Log_Logger *logger, LV2_URID_Map *map, LV2_Log_Log *log)
Definition logger.h:79
uint32_t LV2_URID
Definition urid.h:58
Definition log.h:70
Definition logger.h:43
LV2_URID Warning
Definition logger.h:49
LV2_URID Note
Definition logger.h:47
LV2_URID Trace
Definition logger.h:48
LV2_URID Error
Definition logger.h:46
LV2_Log_Log * log
Definition logger.h:44
Definition urid.h:69
LV2_URID_Map_Handle handle
Definition urid.h:76
LV2_URID(* map)(LV2_URID_Map_Handle handle, const char *uri)
Definition urid.h:99
fmt[0]
Definition fileio.c:2503
#define const
Definition zconf.h:137