log.h 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. /*
  2. (c) Copyright 2001-2009 The world wide DirectFB Open Source Community (directfb.org)
  3. (c) Copyright 2000-2004 Convergence (integrated media) GmbH
  4. All rights reserved.
  5. Written by Denis Oliver Kropp <dok@directfb.org>,
  6. Andreas Hundt <andi@fischlustig.de>,
  7. Sven Neumann <neo@directfb.org>,
  8. Ville Syrjälä <syrjala@sci.fi> and
  9. Claudio Ciccani <klan@users.sf.net>.
  10. This library is free software; you can redistribute it and/or
  11. modify it under the terms of the GNU Lesser General Public
  12. License as published by the Free Software Foundation; either
  13. version 2 of the License, or (at your option) any later version.
  14. This library is distributed in the hope that it will be useful,
  15. but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  17. Lesser General Public License for more details.
  18. You should have received a copy of the GNU Lesser General Public
  19. License along with this library; if not, write to the
  20. Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  21. Boston, MA 02111-1307, USA.
  22. */
  23. #ifndef __DIRECT__LOG_H__
  24. #define __DIRECT__LOG_H__
  25. #include <direct/types.h>
  26. #include <direct/messages.h>
  27. typedef enum {
  28. DLT_STDERR, /* Simply print out log on stderr. */
  29. DLT_FILE, /* Write log into a file. */
  30. DLT_UDP /* Send out log via UDP. */
  31. } DirectLogType;
  32. /*
  33. * Creates a logging facility.
  34. *
  35. * For each 'type' the 'param' has a different meaning:
  36. * DLT_STDERR ignored (leave NULL)
  37. * DLT_FILE file name
  38. * DLT_UDP <ip>:<port>
  39. */
  40. DirectResult direct_log_create ( DirectLogType type,
  41. const char *param,
  42. DirectLog **ret_log );
  43. /*
  44. * Destroys a logging facility.
  45. */
  46. DirectResult direct_log_destroy ( DirectLog *log );
  47. /*
  48. * Write to the log in a printf fashion.
  49. *
  50. * If log is NULL, the default log is used if it's valid,
  51. * otherwise stderr is used a fallback until now.
  52. */
  53. DirectResult direct_log_printf ( DirectLog *log,
  54. const char *format, ... ) D_FORMAT_PRINTF(2);
  55. /*
  56. * Set the default log that's used when no valid log is passed.
  57. */
  58. DirectResult direct_log_set_default( DirectLog *log );
  59. /*
  60. * Locks a logging facility for non-intermixed output of multiple calls in multiple threads. Not mandatory.
  61. */
  62. void direct_log_lock ( DirectLog *log );
  63. /*
  64. * Unlocks a logging facility.
  65. */
  66. void direct_log_unlock ( DirectLog *log );
  67. /*
  68. * Returns the default log.
  69. */
  70. DirectLog *direct_log_default( void );
  71. #endif