aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/libraries/eina/src/lib/eina_log.c
diff options
context:
space:
mode:
Diffstat (limited to 'libraries/eina/src/lib/eina_log.c')
-rw-r--r--libraries/eina/src/lib/eina_log.c145
1 files changed, 143 insertions, 2 deletions
diff --git a/libraries/eina/src/lib/eina_log.c b/libraries/eina/src/lib/eina_log.c
index dd772d2..4e2bb6d 100644
--- a/libraries/eina/src/lib/eina_log.c
+++ b/libraries/eina/src/lib/eina_log.c
@@ -71,6 +71,7 @@
71#define EINA_LOG_ENV_FILE_DISABLE "EINA_LOG_FILE_DISABLE" 71#define EINA_LOG_ENV_FILE_DISABLE "EINA_LOG_FILE_DISABLE"
72#define EINA_LOG_ENV_FUNCTION_DISABLE "EINA_LOG_FUNCTION_DISABLE" 72#define EINA_LOG_ENV_FUNCTION_DISABLE "EINA_LOG_FUNCTION_DISABLE"
73 73
74#ifdef EINA_ENABLE_LOG
74 75
75// Structure for storing domain level settings passed from the command line 76// Structure for storing domain level settings passed from the command line
76// that will be matched with application-defined domains. 77// that will be matched with application-defined domains.
@@ -1294,6 +1295,8 @@ eina_log_print_unlocked(int domain,
1294 abort(); 1295 abort();
1295} 1296}
1296 1297
1298#endif
1299
1297/** 1300/**
1298 * @endcond 1301 * @endcond
1299 */ 1302 */
@@ -1321,6 +1324,7 @@ eina_log_print_unlocked(int domain,
1321Eina_Bool 1324Eina_Bool
1322eina_log_init(void) 1325eina_log_init(void)
1323{ 1326{
1327#ifdef EINA_ENABLE_LOG
1324 const char *level, *tmp; 1328 const char *level, *tmp;
1325 int color_disable; 1329 int color_disable;
1326 1330
@@ -1392,6 +1396,7 @@ eina_log_init(void)
1392 // Parse pending domains passed through EINA_LOG_LEVELS 1396 // Parse pending domains passed through EINA_LOG_LEVELS
1393 eina_log_domain_parse_pendings(); 1397 eina_log_domain_parse_pendings();
1394 1398
1399#endif
1395 return EINA_TRUE; 1400 return EINA_TRUE;
1396} 1401}
1397 1402
@@ -1413,6 +1418,7 @@ eina_log_init(void)
1413Eina_Bool 1418Eina_Bool
1414eina_log_shutdown(void) 1419eina_log_shutdown(void)
1415{ 1420{
1421#ifdef EINA_ENABLE_LOG
1416 Eina_Inlist *tmp; 1422 Eina_Inlist *tmp;
1417 1423
1418 while (_log_domains_count--) 1424 while (_log_domains_count--)
@@ -1443,6 +1449,7 @@ eina_log_shutdown(void)
1443 free(tmp); 1449 free(tmp);
1444 } 1450 }
1445 1451
1452#endif
1446 return EINA_TRUE; 1453 return EINA_TRUE;
1447} 1454}
1448 1455
@@ -1460,10 +1467,12 @@ eina_log_shutdown(void)
1460void 1467void
1461eina_log_threads_init(void) 1468eina_log_threads_init(void)
1462{ 1469{
1470#ifdef EINA_ENABLE_LOG
1463 if (_threads_inited) return; 1471 if (_threads_inited) return;
1464 _main_thread = SELF(); 1472 _main_thread = SELF();
1465 if (!INIT()) return; 1473 if (!INIT()) return;
1466 _threads_inited = EINA_TRUE; 1474 _threads_inited = EINA_TRUE;
1475#endif
1467} 1476}
1468 1477
1469/** 1478/**
@@ -1478,11 +1487,13 @@ eina_log_threads_init(void)
1478void 1487void
1479eina_log_threads_shutdown(void) 1488eina_log_threads_shutdown(void)
1480{ 1489{
1490#ifdef EINA_ENABLE_LOG
1481 if (!_threads_inited) return; 1491 if (!_threads_inited) return;
1482 CHECK_MAIN(); 1492 CHECK_MAIN();
1483 SHUTDOWN(); 1493 SHUTDOWN();
1484 _threads_enabled = EINA_FALSE; 1494 _threads_enabled = EINA_FALSE;
1485 _threads_inited = EINA_FALSE; 1495 _threads_inited = EINA_FALSE;
1496#endif
1486} 1497}
1487 1498
1488#endif 1499#endif
@@ -1504,7 +1515,7 @@ EAPI int EINA_LOG_DOMAIN_GLOBAL = 0;
1504EAPI void 1515EAPI void
1505eina_log_threads_enable(void) 1516eina_log_threads_enable(void)
1506{ 1517{
1507#ifdef EFL_HAVE_THREADS 1518#if defined (EFL_HAVE_THREADS) && defined (EINA_ENABLE_LOG)
1508 if (_threads_enabled) return; 1519 if (_threads_enabled) return;
1509 if (!_threads_inited) eina_log_threads_init(); 1520 if (!_threads_inited) eina_log_threads_init();
1510 _threads_enabled = EINA_TRUE; 1521 _threads_enabled = EINA_TRUE;
@@ -1515,32 +1526,45 @@ eina_log_threads_enable(void)
1515EAPI void 1526EAPI void
1516eina_log_print_cb_set(Eina_Log_Print_Cb cb, void *data) 1527eina_log_print_cb_set(Eina_Log_Print_Cb cb, void *data)
1517{ 1528{
1529#ifdef EINA_ENABLE_LOG
1518 LOG_LOCK(); 1530 LOG_LOCK();
1519 _print_cb = cb; 1531 _print_cb = cb;
1520 _print_cb_data = data; 1532 _print_cb_data = data;
1521 eina_log_print_prefix_update(); 1533 eina_log_print_prefix_update();
1522 LOG_UNLOCK(); 1534 LOG_UNLOCK();
1535#else
1536 (void) cb;
1537 (void) data;
1538#endif
1523} 1539}
1524 1540
1525EAPI void 1541EAPI void
1526eina_log_level_set(int level) 1542eina_log_level_set(int level)
1527{ 1543{
1544#ifdef EINA_ENABLE_LOG
1528 _log_level = level; 1545 _log_level = level;
1529 if (EINA_LIKELY((EINA_LOG_DOMAIN_GLOBAL >= 0) && 1546 if (EINA_LIKELY((EINA_LOG_DOMAIN_GLOBAL >= 0) &&
1530 ((unsigned int)EINA_LOG_DOMAIN_GLOBAL < _log_domains_count))) 1547 ((unsigned int)EINA_LOG_DOMAIN_GLOBAL < _log_domains_count)))
1531 _log_domains[EINA_LOG_DOMAIN_GLOBAL].level = level; 1548 _log_domains[EINA_LOG_DOMAIN_GLOBAL].level = level;
1549#else
1550 (void) level;
1551#endif
1532} 1552}
1533 1553
1534EAPI int 1554EAPI int
1535eina_log_level_get(void) 1555eina_log_level_get(void)
1536{ 1556{
1557#ifdef EINA_ENABLE_LOG
1537 return _log_level; 1558 return _log_level;
1559#else
1560 return 0;
1561#endif
1538} 1562}
1539 1563
1540EAPI Eina_Bool 1564EAPI Eina_Bool
1541eina_log_main_thread_check(void) 1565eina_log_main_thread_check(void)
1542{ 1566{
1543#ifdef EFL_HAVE_THREADS 1567#if defined (EFL_HAVE_THREADS) && defined (EINA_ENABLE_LOG)
1544 return ((!_threads_enabled) || IS_MAIN(SELF())); 1568 return ((!_threads_enabled) || IS_MAIN(SELF()));
1545#else 1569#else
1546 return EINA_TRUE; 1570 return EINA_TRUE;
@@ -1550,66 +1574,107 @@ eina_log_main_thread_check(void)
1550EAPI void 1574EAPI void
1551eina_log_color_disable_set(Eina_Bool disabled) 1575eina_log_color_disable_set(Eina_Bool disabled)
1552{ 1576{
1577#ifdef EINA_ENABLE_LOG
1553 _disable_color = disabled; 1578 _disable_color = disabled;
1579#else
1580 (void) disabled;
1581#endif
1554} 1582}
1555 1583
1556EAPI Eina_Bool 1584EAPI Eina_Bool
1557eina_log_color_disable_get(void) 1585eina_log_color_disable_get(void)
1558{ 1586{
1587#ifdef EINA_ENABLE_LOG
1559 return _disable_color; 1588 return _disable_color;
1589#else
1590 return EINA_TRUE;
1591#endif
1560} 1592}
1561 1593
1562EAPI void 1594EAPI void
1563eina_log_file_disable_set(Eina_Bool disabled) 1595eina_log_file_disable_set(Eina_Bool disabled)
1564{ 1596{
1597#ifdef EINA_ENABLE_LOG
1565 _disable_file = disabled; 1598 _disable_file = disabled;
1599#else
1600 (void) disabled;
1601#endif
1566} 1602}
1567 1603
1568EAPI Eina_Bool 1604EAPI Eina_Bool
1569eina_log_file_disable_get(void) 1605eina_log_file_disable_get(void)
1570{ 1606{
1607#ifdef EINA_ENABLE_LOG
1571 return _disable_file; 1608 return _disable_file;
1609#else
1610 return EINA_TRUE;
1611#endif
1572} 1612}
1573 1613
1574EAPI void 1614EAPI void
1575eina_log_function_disable_set(Eina_Bool disabled) 1615eina_log_function_disable_set(Eina_Bool disabled)
1576{ 1616{
1617#ifdef EINA_ENABLE_LOG
1577 _disable_function = disabled; 1618 _disable_function = disabled;
1619#else
1620 (void) disabled;
1621#endif
1578} 1622}
1579 1623
1580EAPI Eina_Bool 1624EAPI Eina_Bool
1581eina_log_function_disable_get(void) 1625eina_log_function_disable_get(void)
1582{ 1626{
1627#ifdef EINA_ENABLE_LOG
1583 return _disable_function; 1628 return _disable_function;
1629#else
1630 return EINA_TRUE;
1631#endif
1584} 1632}
1585 1633
1586EAPI void 1634EAPI void
1587eina_log_abort_on_critical_set(Eina_Bool abort_on_critical) 1635eina_log_abort_on_critical_set(Eina_Bool abort_on_critical)
1588{ 1636{
1637#ifdef EINA_ENABLE_LOG
1589 _abort_on_critical = abort_on_critical; 1638 _abort_on_critical = abort_on_critical;
1639#else
1640 (void) abort_on_critical;
1641#endif
1590} 1642}
1591 1643
1592EAPI Eina_Bool 1644EAPI Eina_Bool
1593eina_log_abort_on_critical_get(void) 1645eina_log_abort_on_critical_get(void)
1594{ 1646{
1647#ifdef EINA_ENABLE_LOG
1595 return _abort_on_critical; 1648 return _abort_on_critical;
1649#else
1650 return EINA_FALSE;
1651#endif
1596} 1652}
1597 1653
1598EAPI void 1654EAPI void
1599eina_log_abort_on_critical_level_set(int critical_level) 1655eina_log_abort_on_critical_level_set(int critical_level)
1600{ 1656{
1657#ifdef EINA_ENABLE_LOG
1601 _abort_level_on_critical = critical_level; 1658 _abort_level_on_critical = critical_level;
1659#else
1660 (void) critical_level;
1661#endif
1602} 1662}
1603 1663
1604EAPI int 1664EAPI int
1605eina_log_abort_on_critical_level_get(void) 1665eina_log_abort_on_critical_level_get(void)
1606{ 1666{
1667#ifdef EINA_ENABLE_LOG
1607 return _abort_level_on_critical; 1668 return _abort_level_on_critical;
1669#else
1670 return 0;
1671#endif
1608} 1672}
1609 1673
1610EAPI int 1674EAPI int
1611eina_log_domain_register(const char *name, const char *color) 1675eina_log_domain_register(const char *name, const char *color)
1612{ 1676{
1677#ifdef EINA_ENABLE_LOG
1613 int r; 1678 int r;
1614 1679
1615 EINA_SAFETY_ON_NULL_RETURN_VAL(name, -1); 1680 EINA_SAFETY_ON_NULL_RETURN_VAL(name, -1);
@@ -1618,20 +1683,30 @@ eina_log_domain_register(const char *name, const char *color)
1618 r = eina_log_domain_register_unlocked(name, color); 1683 r = eina_log_domain_register_unlocked(name, color);
1619 LOG_UNLOCK(); 1684 LOG_UNLOCK();
1620 return r; 1685 return r;
1686#else
1687 (void) name;
1688 (void) color;
1689 return 0;
1690#endif
1621} 1691}
1622 1692
1623EAPI void 1693EAPI void
1624eina_log_domain_unregister(int domain) 1694eina_log_domain_unregister(int domain)
1625{ 1695{
1696#ifdef EINA_ENABLE_LOG
1626 EINA_SAFETY_ON_FALSE_RETURN(domain >= 0); 1697 EINA_SAFETY_ON_FALSE_RETURN(domain >= 0);
1627 LOG_LOCK(); 1698 LOG_LOCK();
1628 eina_log_domain_unregister_unlocked(domain); 1699 eina_log_domain_unregister_unlocked(domain);
1629 LOG_UNLOCK(); 1700 LOG_UNLOCK();
1701#else
1702 (void) domain;
1703#endif
1630} 1704}
1631 1705
1632EAPI void 1706EAPI void
1633eina_log_domain_level_set(const char *domain_name, int level) 1707eina_log_domain_level_set(const char *domain_name, int level)
1634{ 1708{
1709#ifdef EINA_ENABLE_LOG
1635 Eina_Log_Domain_Level_Pending *pending; 1710 Eina_Log_Domain_Level_Pending *pending;
1636 size_t namelen; 1711 size_t namelen;
1637 unsigned int i; 1712 unsigned int i;
@@ -1672,11 +1747,16 @@ eina_log_domain_level_set(const char *domain_name, int level)
1672 memcpy(pending->name, domain_name, namelen + 1); 1747 memcpy(pending->name, domain_name, namelen + 1);
1673 1748
1674 _pending_list = eina_inlist_append(_pending_list, EINA_INLIST_GET(pending)); 1749 _pending_list = eina_inlist_append(_pending_list, EINA_INLIST_GET(pending));
1750#else
1751 (void) domain_name;
1752 (void) level;
1753#endif
1675} 1754}
1676 1755
1677EAPI int 1756EAPI int
1678eina_log_domain_level_get(const char *domain_name) 1757eina_log_domain_level_get(const char *domain_name)
1679{ 1758{
1759#ifdef EINA_ENABLE_LOG
1680 Eina_Log_Domain_Level_Pending *pending; 1760 Eina_Log_Domain_Level_Pending *pending;
1681 size_t namelen; 1761 size_t namelen;
1682 unsigned int i; 1762 unsigned int i;
@@ -1711,17 +1791,26 @@ eina_log_domain_level_get(const char *domain_name)
1711 } 1791 }
1712 1792
1713 return _log_level; 1793 return _log_level;
1794#else
1795 (void) domain_name;
1796 return 0;
1797#endif
1714} 1798}
1715 1799
1716EAPI int 1800EAPI int
1717eina_log_domain_registered_level_get(int domain) 1801eina_log_domain_registered_level_get(int domain)
1718{ 1802{
1803#ifdef EINA_ENABLE_LOG
1719 EINA_SAFETY_ON_FALSE_RETURN_VAL(domain >= 0, EINA_LOG_LEVEL_UNKNOWN); 1804 EINA_SAFETY_ON_FALSE_RETURN_VAL(domain >= 0, EINA_LOG_LEVEL_UNKNOWN);
1720 EINA_SAFETY_ON_FALSE_RETURN_VAL((unsigned int)domain < _log_domains_count, 1805 EINA_SAFETY_ON_FALSE_RETURN_VAL((unsigned int)domain < _log_domains_count,
1721 EINA_LOG_LEVEL_UNKNOWN); 1806 EINA_LOG_LEVEL_UNKNOWN);
1722 EINA_SAFETY_ON_TRUE_RETURN_VAL(_log_domains[domain].deleted, 1807 EINA_SAFETY_ON_TRUE_RETURN_VAL(_log_domains[domain].deleted,
1723 EINA_LOG_LEVEL_UNKNOWN); 1808 EINA_LOG_LEVEL_UNKNOWN);
1724 return _log_domains[domain].level; 1809 return _log_domains[domain].level;
1810#else
1811 (void) domain;
1812 return 0;
1813#endif
1725} 1814}
1726 1815
1727EAPI void 1816EAPI void
@@ -1734,9 +1823,20 @@ eina_log_print_cb_stderr(const Eina_Log_Domain *d,
1734 __UNUSED__ void *data, 1823 __UNUSED__ void *data,
1735 va_list args) 1824 va_list args)
1736{ 1825{
1826#ifdef EINA_ENABLE_LOG
1737 _eina_log_print_prefix(stderr, d, level, file, fnc, line); 1827 _eina_log_print_prefix(stderr, d, level, file, fnc, line);
1738 vfprintf(stderr, fmt, args); 1828 vfprintf(stderr, fmt, args);
1739 putc('\n', stderr); 1829 putc('\n', stderr);
1830#else
1831 (void) d;
1832 (void) level;
1833 (void) file;
1834 (void) fnc;
1835 (void) line;
1836 (void) fmt;
1837 (void) data;
1838 (void) args;
1839#endif
1740} 1840}
1741 1841
1742EAPI void 1842EAPI void
@@ -1749,9 +1849,20 @@ eina_log_print_cb_stdout(const Eina_Log_Domain *d,
1749 __UNUSED__ void *data, 1849 __UNUSED__ void *data,
1750 va_list args) 1850 va_list args)
1751{ 1851{
1852#ifdef EINA_ENABLE_LOG
1752 _eina_log_print_prefix(stdout, d, level, file, fnc, line); 1853 _eina_log_print_prefix(stdout, d, level, file, fnc, line);
1753 vprintf(fmt, args); 1854 vprintf(fmt, args);
1754 putchar('\n'); 1855 putchar('\n');
1856#else
1857 (void) d;
1858 (void) level;
1859 (void) file;
1860 (void) fnc;
1861 (void) line;
1862 (void) fmt;
1863 (void) data;
1864 (void) args;
1865#endif
1755} 1866}
1756 1867
1757EAPI void 1868EAPI void
@@ -1764,6 +1875,7 @@ eina_log_print_cb_file(const Eina_Log_Domain *d,
1764 void *data, 1875 void *data,
1765 va_list args) 1876 va_list args)
1766{ 1877{
1878#ifdef EINA_ENABLE_LOG
1767 FILE *f = data; 1879 FILE *f = data;
1768#ifdef EFL_HAVE_THREADS 1880#ifdef EFL_HAVE_THREADS
1769 if (_threads_enabled) 1881 if (_threads_enabled)
@@ -1787,12 +1899,22 @@ end:
1787#endif 1899#endif
1788 vfprintf(f, fmt, args); 1900 vfprintf(f, fmt, args);
1789 putc('\n', f); 1901 putc('\n', f);
1902#else
1903 (void) d;
1904 (void) file;
1905 (void) fnc;
1906 (void) line;
1907 (void) fmt;
1908 (void) data;
1909 (void) args;
1910#endif
1790} 1911}
1791 1912
1792EAPI void 1913EAPI void
1793eina_log_print(int domain, Eina_Log_Level level, const char *file, 1914eina_log_print(int domain, Eina_Log_Level level, const char *file,
1794 const char *fnc, int line, const char *fmt, ...) 1915 const char *fnc, int line, const char *fmt, ...)
1795{ 1916{
1917#ifdef EINA_ENABLE_LOG
1796 va_list args; 1918 va_list args;
1797 1919
1798#ifdef EINA_SAFETY_CHECKS 1920#ifdef EINA_SAFETY_CHECKS
@@ -1820,12 +1942,22 @@ eina_log_print(int domain, Eina_Log_Level level, const char *file,
1820 eina_log_print_unlocked(domain, level, file, fnc, line, fmt, args); 1942 eina_log_print_unlocked(domain, level, file, fnc, line, fmt, args);
1821 LOG_UNLOCK(); 1943 LOG_UNLOCK();
1822 va_end(args); 1944 va_end(args);
1945#else
1946 (void) domain;
1947 (void) level;
1948 (void) file;
1949 (void) fnc;
1950 (void) line;
1951 (void) fmt;
1952#endif
1823} 1953}
1824 1954
1825EAPI void 1955EAPI void
1826eina_log_vprint(int domain, Eina_Log_Level level, const char *file, 1956eina_log_vprint(int domain, Eina_Log_Level level, const char *file,
1827 const char *fnc, int line, const char *fmt, va_list args) 1957 const char *fnc, int line, const char *fmt, va_list args)
1828{ 1958{
1959#ifdef EINA_ENABLE_LOG
1960
1829#ifdef EINA_SAFETY_CHECKS 1961#ifdef EINA_SAFETY_CHECKS
1830 if (EINA_UNLIKELY(!file)) 1962 if (EINA_UNLIKELY(!file))
1831 { 1963 {
@@ -1849,4 +1981,13 @@ eina_log_vprint(int domain, Eina_Log_Level level, const char *file,
1849 LOG_LOCK(); 1981 LOG_LOCK();
1850 eina_log_print_unlocked(domain, level, file, fnc, line, fmt, args); 1982 eina_log_print_unlocked(domain, level, file, fnc, line, fmt, args);
1851 LOG_UNLOCK(); 1983 LOG_UNLOCK();
1984#else
1985 (void) domain;
1986 (void) level;
1987 (void) file;
1988 (void) fnc;
1989 (void) line;
1990 (void) fmt;
1991 (void) args;
1992#endif
1852} 1993}