12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
- /*
- * priority.c
- *
- * Copyright 2001-2003, Meiosys (www.meiosys.com). All rights reserved.
- *
- * See the COPYING file for the terms of usage and distribution.
- */
- #include <tchar.h>
- #include <string.h>
- #include "log4c/priority.h"
- #include "sd/sd_xplatform.h"
- static const TCHAR version[] = _T("$Id$");
- static const TCHAR* const priorities[] = {
- _T("FATAL"),
- _T("ALERT"),
- _T("CRIT"),
- _T("ERROR"),
- _T("WARN"),
- _T("NOTICE"),
- _T("INFO"),
- _T("DEBUG"),
- _T("TRACE"),
- _T("NOTSET"),
- _T("UNKNOWN")
- };
- static const size_t npriorities = sizeof(priorities) / sizeof(priorities[0]);
- /*******************************************************************************/
- extern const TCHAR* log4c_priority_to_string(int a_priority)
- {
- a_priority /= 100;
- if ( (a_priority < 0) || (a_priority > 10) )
- a_priority = 10;
- return priorities[a_priority];
- }
- /*******************************************************************************/
- extern int log4c_priority_to_int(const TCHAR* a_priority_name)
- {
- size_t i;
- if (a_priority_name) {
- for (i = 0; i < npriorities; i++) {
- if (!strncasecmp(priorities[i], a_priority_name, _tcsclen(priorities[i])))
- return i * 100;
- }
- }
- return LOG4C_PRIORITY_UNKNOWN;
- }
|