Skip to content

Commit

Permalink
up
Browse files Browse the repository at this point in the history
  • Loading branch information
zsummer committed Sep 27, 2017
1 parent d3741cb commit e241f3e
Showing 1 changed file with 51 additions and 45 deletions.
96 changes: 51 additions & 45 deletions log4z.h
Original file line number Diff line number Diff line change
Expand Up @@ -158,21 +158,21 @@
* support system: windows, linux, mac, iOS
*
* VERSION 3.1 <DATE: 2014.12.19>
* add method enable/disable logger by specific logger id
* add method enable/disable log suffix line number.
* add method enable/disable logger by specific logger id
* add method enable/disable log suffix line number.
* add method enable/disable log output to file.
*
* VERSION 3.2 <DATE: 2014.12.19>
* add interface setLoggerName,setLoggerPath,setAutoUpdate
* add interface setLoggerName,setLoggerPath,setAutoUpdate
* support auto update from configure file
*
* VERSION 3.3 <DATE: 2014.12.19>
* support map vector list
* support continuum via travis.
* new hot change design, all change realize need via push log flow.
* support oem string convert.
* new method to read whole content of file.
* check configure's checksum when auto update it.
* support map vector list
* support continuum via travis.
* new hot change design, all change realize need via push log flow.
* support oem string convert.
* new method to read whole content of file.
* check configure's checksum when auto update it.
* some other optimize.
*
* VERSION 3.5 <DATE: 2017.08.20>
Expand All @@ -190,6 +190,7 @@
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <cmath>
#include <stdlib.h>
#ifdef WIN32
#define WIN32_LEAN_AND_MEAN
Expand Down Expand Up @@ -706,36 +707,36 @@ inline Log4zStream & Log4zStream::writeULongLong(unsigned long long t, int width
static const char * lut =
"0123456789abcdef";

static const char *lutDec =
"00010203040506070809"
"10111213141516171819"
"20212223242526272829"
"30313233343536373839"
"40414243444546474849"
"50515253545556575859"
"60616263646566676869"
"70717273747576777879"
static const char *lutDec =
"00010203040506070809"
"10111213141516171819"
"20212223242526272829"
"30313233343536373839"
"40414243444546474849"
"50515253545556575859"
"60616263646566676869"
"70717273747576777879"
"80818283848586878889"
"90919293949596979899";

static const char *lutHex =
"000102030405060708090A0B0C0D0E0F"
"101112131415161718191A1B1C1D1E1F"
"202122232425262728292A2B2C2D2E2F"
"303132333435363738393A3B3C3D3E3F"
"404142434445464748494A4B4C4D4E4F"
"505152535455565758595A5B5C5D5E5F"
"606162636465666768696A6B6C6D6E6F"
"707172737475767778797A7B7C7D7E7F"
"808182838485868788898A8B8C8D8E8F"
"909192939495969798999A9B9C9D9E9F"
"A0A1A2A3A4A5A6A7A8A9AAABACADAEAF"
"B0B1B2B3B4B5B6B7B8B9BABBBCBDBEBF"
"C0C1C2C3C4C5C6C7C8C9CACBCCCDCECF"
"D0D1D2D3D4D5D6D7D8D9DADBDCDDDEDF"
"E0E1E2E3E4E5E6E7E8E9EAEBECEDEEEF"
"F0F1F2F3F4F5F6F7F8F9FAFBFCFDFEFF";

static const char *lutHex =
"000102030405060708090A0B0C0D0E0F"
"101112131415161718191A1B1C1D1E1F"
"202122232425262728292A2B2C2D2E2F"
"303132333435363738393A3B3C3D3E3F"
"404142434445464748494A4B4C4D4E4F"
"505152535455565758595A5B5C5D5E5F"
"606162636465666768696A6B6C6D6E6F"
"707172737475767778797A7B7C7D7E7F"
"808182838485868788898A8B8C8D8E8F"
"909192939495969798999A9B9C9D9E9F"
"A0A1A2A3A4A5A6A7A8A9AAABACADAEAF"
"B0B1B2B3B4B5B6B7B8B9BABBBCBDBEBF"
"C0C1C2C3C4C5C6C7C8C9CACBCCCDCECF"
"D0D1D2D3D4D5D6D7D8D9DADBDCDDDEDF"
"E0E1E2E3E4E5E6E7E8E9EAEBECEDEEEF"
"F0F1F2F3F4F5F6F7F8F9FAFBFCFDFEFF";

const unsigned long long cacheSize = 64;

if ((unsigned long long)(_end - _cur) > cacheSize)
Expand All @@ -746,7 +747,7 @@ inline Log4zStream & Log4zStream::writeULongLong(unsigned long long t, int width
unsigned long long digit = 0;




if (dec == 10)
{
do
Expand Down Expand Up @@ -802,22 +803,27 @@ inline Log4zStream & Log4zStream::writeULongLong(unsigned long long t, int width
inline Log4zStream & Log4zStream::writeDouble(double t, bool isSimple)
{

if (t != t)
#if __cplusplus >= 201103L
using std::isnan;
using std::isinf;
#endif
if (isnan(t))
{
writeString("nan", 3);
return *this;
}
else if (t <= 1.7976931348623158e+308 && t >= -1.7976931348623158e+308)
else if (isinf(t))
{
writeString("inf", 3);
return *this;
}



size_t count = _end - _cur;
double fabst = fabs(t);
if (count > 30)
{
if (count > 30)
{
if ( fabst < 0.0001 || (!isSimple && fabst > 4503599627370495ULL) || (isSimple && fabst > 8388607))
{
gcvt(t, isSimple ? 7 : 16, _cur);
Expand All @@ -828,9 +834,9 @@ inline Log4zStream & Log4zStream::writeDouble(double t, bool isSimple)
}
else
{
if (t < 0.0)
{
writeChar('-');
if (t < 0.0)
{
writeChar('-');
}
double intpart = 0;
unsigned long long fractpart = (unsigned long long)(modf(fabst, &intpart) * 10000);
Expand All @@ -840,7 +846,7 @@ inline Log4zStream & Log4zStream::writeDouble(double t, bool isSimple)
writeChar('.');
writeULongLong(fractpart, 4);
}
}
}
}

return *this;
Expand Down

0 comments on commit e241f3e

Please # to comment.