1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150
|
/*
Copyright (C) 2006 Adam Charrett
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
logging.h
Logging levels and functions.
*/
#ifndef _LOGGING_H
#define _LOGGING_H
#include <stdarg.h>
#include <pthread.h>
#include "types.h"
/**
* Error logging level, always printed used for fatal error messages.
*/
#define LOG_ERROR 0
/**
* Information logging level, used for warnings and other information.
*/
#define LOG_INFO 1
/**
* Verbose Information logging level, less important than information level but
* not quite debugging.
*/
#define LOG_INFOV 2 /* Verbose information */
/**
* Debug Logging Level, useful debugging information.
*/
#define LOG_DEBUG 3
/**
* Verbose Debugging Level, less useful debugging information.
*/
#define LOG_DEBUGV 4 /* Verbose debugging info */
/**
* Diarrhee level, lots and lots of pointless text.
*/
#define LOG_DIARRHEA 10
/**
* @internal
* Initialises logging, by first attempting to create the log file in /var/log,
* then if unsuccessful in ~/.dvbstreamer
* @param filename Name of the log file to create.
* @param logLevel The initial logging/verbosity level.
* @return 0 on success.
*/
int LoggingInit(char *filename, int logLevel);
/**
* @internal
* Initialises logging by using the file path specified as the log file.
* @param filepath File path of the file to use for logging.
* @param logLevel The initial logging/verbosity level.
* @return 0 on success.
*/
int LoggingInitFile(char *filename, int logLevel);
/**
* @internal
* Redirects STDOUT and STDERR file descriptors to use the file descriptor opened
* for log output.
*/
void LoggingRedirectStdErrStdOut(void);
/**
* @internal
* Deinitialise logging.
*/
void LoggingDeInit(void);
/**
* Set the current logging level.
* @param level The new level to set.
*/
void LogLevelSet(int level);
/**
* Retrieves the current logging level.
* @return The current logging level.
*/
int LogLevelGet(void);
/**
* Increase the logging level by 1.
*/
void LogLevelInc(void);
/**
* Decrease the logging level by 1.
*/
void LogLevelDec(void);
/**
* Determine if the specified logging level is enabled.
* @param level The level to check.
* @return TRUE if the level is enabled, FALSE otherwise.
*/
bool LogLevelIsEnabled(int level);
/**
* Load module/level settings so that levels can be set for specific modules.
* @param path Path to file to load.
*/
void LogLoadModuleLevels(const char *path);
/**
* Register a name for a pthread. The name will be used instead of the numeric
* id in the log output.
* @param thread pthread to register.
* @param name Name of the thread.
*/
void LogRegisterThread(pthread_t thread, const char *name);
/**
* Unregister a name of a pthread.
* @param thread pthread to unregister.
*/
void LogUnregisterThread(pthread_t thread);
/**
* Write the text describe by format to the log output, if the current verbosity
* level is greater or equal to level.
* @param level The level at which to output this text.
* @param module The module that is doing the logging.
* @param format String in printf format to output.
*/
extern void LogModule(int level, const char *module, char *format, ...);
#endif
|