Assists music production by grouping standalone programs into sessions. Community version of "Non Session Manager".
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

72 lines
2.6KB

  1. /*******************************************************************************/
  2. /* Copyright (C) 2008-2020 Jonathan Moore Liles (as "Non-Session-Manager") */
  3. /* Copyright (C) 2020- Nils Hilbricht */
  4. /* */
  5. /* This file is part of New-Session-Manager */
  6. /* */
  7. /* New-Session-Manager is free software: you can redistribute it and/or modify */
  8. /* it under the terms of the GNU General Public License as published by */
  9. /* the Free Software Foundation, either version 3 of the License, or */
  10. /* (at your option) any later version. */
  11. /* */
  12. /* New-Session-Manager is distributed in the hope that it will be useful, */
  13. /* but WITHOUT ANY WARRANTY; without even the implied warranty of */
  14. /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
  15. /* GNU General Public License for more details. */
  16. /* */
  17. /* You should have received a copy of the GNU General Public License */
  18. /* along with New-Session-Manager. If not, see <https://www.gnu.org/licenses/>.*/
  19. /*******************************************************************************/
  20. #include "debug.h"
  21. #include <string.h>
  22. #include <stdio.h>
  23. #include <stdarg.h>
  24. extern char * program_invocation_short_name;
  25. void
  26. warnf ( warning_t level,
  27. const char *module,
  28. const char *file,
  29. const char *function, int line, const char *fmt, ... )
  30. {
  31. va_list args;
  32. static const char *level_tab[] = {
  33. "message", "\033[1;32m",
  34. "warning", "\033[1;33m",
  35. "assertion", "\033[1;31m"
  36. };
  37. module = program_invocation_short_name;
  38. if ( module )
  39. fprintf( stderr, "[\033[1;30m%s\033[0m] ", module );
  40. #ifndef NDEBUG
  41. if ( file )
  42. fprintf( stderr, "%s", file );
  43. if ( line )
  44. fprintf( stderr, ":%i", line );
  45. if ( function )
  46. fprintf( stderr, " %s()", function );
  47. fprintf( stderr, ": " );
  48. #endif
  49. if ( unsigned( ( level << 1 ) + 1 ) <
  50. ( sizeof( level_tab ) / sizeof( level_tab[0] ) ) )
  51. fprintf( stderr, "%s", level_tab[( level << 1 ) + 1] );
  52. if ( fmt )
  53. {
  54. va_start( args, fmt );
  55. vfprintf( stderr, fmt, args );
  56. va_end( args );
  57. }
  58. fprintf( stderr, "\033[0m\n" );
  59. }