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.

log.c 1.5KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. /*
  2. * Copyright (C) 2012 Michael Brown <mbrown@fensystems.co.uk>.
  3. *
  4. * This program is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU General Public License as
  6. * published by the Free Software Foundation; either version 2 of the
  7. * License, or any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful, but
  10. * WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. * General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program; if not, write to the Free Software
  16. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  17. */
  18. FILE_LICENCE ( GPL2_OR_LATER );
  19. /** @file
  20. *
  21. * System logger
  22. *
  23. */
  24. #include <stdarg.h>
  25. #include <syslog.h>
  26. #include <ipxe/console.h>
  27. /**
  28. * Write message to system log
  29. *
  30. * @v fmt Format string
  31. * @v args Arguments
  32. */
  33. void log_vprintf ( const char *fmt, va_list args ) {
  34. int saved_usage;
  35. /* Mark console as in use for log messages */
  36. saved_usage = console_set_usage ( CONSOLE_USAGE_LOG );
  37. /* Print message */
  38. vprintf ( fmt, args );
  39. /* Restore console usage */
  40. console_set_usage ( saved_usage );
  41. }
  42. /**
  43. * Write message to system log
  44. *
  45. * @v fmt Format string
  46. * @v ... Arguments
  47. */
  48. void log_printf ( const char *fmt, ... ) {
  49. va_list args;
  50. va_start ( args, fmt );
  51. log_vprintf ( fmt, args );
  52. va_end ( args );
  53. }