Skip to content

Commit e241f3e

Browse files
committed
up
1 parent d3741cb commit e241f3e

File tree

1 file changed

+51
-45
lines changed

1 file changed

+51
-45
lines changed

log4z.h

Lines changed: 51 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -158,21 +158,21 @@
158158
* support system: windows, linux, mac, iOS
159159
*
160160
* VERSION 3.1 <DATE: 2014.12.19>
161-
* add method enable/disable logger by specific logger id
162-
* add method enable/disable log suffix line number.
161+
* add method enable/disable logger by specific logger id
162+
* add method enable/disable log suffix line number.
163163
* add method enable/disable log output to file.
164164
*
165165
* VERSION 3.2 <DATE: 2014.12.19>
166-
* add interface setLoggerName,setLoggerPath,setAutoUpdate
166+
* add interface setLoggerName,setLoggerPath,setAutoUpdate
167167
* support auto update from configure file
168168
*
169169
* VERSION 3.3 <DATE: 2014.12.19>
170-
* support map vector list
171-
* support continuum via travis.
172-
* new hot change design, all change realize need via push log flow.
173-
* support oem string convert.
174-
* new method to read whole content of file.
175-
* check configure's checksum when auto update it.
170+
* support map vector list
171+
* support continuum via travis.
172+
* new hot change design, all change realize need via push log flow.
173+
* support oem string convert.
174+
* new method to read whole content of file.
175+
* check configure's checksum when auto update it.
176176
* some other optimize.
177177
*
178178
* VERSION 3.5 <DATE: 2017.08.20>
@@ -190,6 +190,7 @@
190190
#include <stdio.h>
191191
#include <string.h>
192192
#include <math.h>
193+
#include <cmath>
193194
#include <stdlib.h>
194195
#ifdef WIN32
195196
#define WIN32_LEAN_AND_MEAN
@@ -706,36 +707,36 @@ inline Log4zStream & Log4zStream::writeULongLong(unsigned long long t, int width
706707
static const char * lut =
707708
"0123456789abcdef";
708709

709-
static const char *lutDec =
710-
"00010203040506070809"
711-
"10111213141516171819"
712-
"20212223242526272829"
713-
"30313233343536373839"
714-
"40414243444546474849"
715-
"50515253545556575859"
716-
"60616263646566676869"
717-
"70717273747576777879"
710+
static const char *lutDec =
711+
"00010203040506070809"
712+
"10111213141516171819"
713+
"20212223242526272829"
714+
"30313233343536373839"
715+
"40414243444546474849"
716+
"50515253545556575859"
717+
"60616263646566676869"
718+
"70717273747576777879"
718719
"80818283848586878889"
719720
"90919293949596979899";
720721

721-
static const char *lutHex =
722-
"000102030405060708090A0B0C0D0E0F"
723-
"101112131415161718191A1B1C1D1E1F"
724-
"202122232425262728292A2B2C2D2E2F"
725-
"303132333435363738393A3B3C3D3E3F"
726-
"404142434445464748494A4B4C4D4E4F"
727-
"505152535455565758595A5B5C5D5E5F"
728-
"606162636465666768696A6B6C6D6E6F"
729-
"707172737475767778797A7B7C7D7E7F"
730-
"808182838485868788898A8B8C8D8E8F"
731-
"909192939495969798999A9B9C9D9E9F"
732-
"A0A1A2A3A4A5A6A7A8A9AAABACADAEAF"
733-
"B0B1B2B3B4B5B6B7B8B9BABBBCBDBEBF"
734-
"C0C1C2C3C4C5C6C7C8C9CACBCCCDCECF"
735-
"D0D1D2D3D4D5D6D7D8D9DADBDCDDDEDF"
736-
"E0E1E2E3E4E5E6E7E8E9EAEBECEDEEEF"
737-
"F0F1F2F3F4F5F6F7F8F9FAFBFCFDFEFF";
738-
722+
static const char *lutHex =
723+
"000102030405060708090A0B0C0D0E0F"
724+
"101112131415161718191A1B1C1D1E1F"
725+
"202122232425262728292A2B2C2D2E2F"
726+
"303132333435363738393A3B3C3D3E3F"
727+
"404142434445464748494A4B4C4D4E4F"
728+
"505152535455565758595A5B5C5D5E5F"
729+
"606162636465666768696A6B6C6D6E6F"
730+
"707172737475767778797A7B7C7D7E7F"
731+
"808182838485868788898A8B8C8D8E8F"
732+
"909192939495969798999A9B9C9D9E9F"
733+
"A0A1A2A3A4A5A6A7A8A9AAABACADAEAF"
734+
"B0B1B2B3B4B5B6B7B8B9BABBBCBDBEBF"
735+
"C0C1C2C3C4C5C6C7C8C9CACBCCCDCECF"
736+
"D0D1D2D3D4D5D6D7D8D9DADBDCDDDEDF"
737+
"E0E1E2E3E4E5E6E7E8E9EAEBECEDEEEF"
738+
"F0F1F2F3F4F5F6F7F8F9FAFBFCFDFEFF";
739+
739740
const unsigned long long cacheSize = 64;
740741

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

748749

749-
750+
750751
if (dec == 10)
751752
{
752753
do
@@ -802,22 +803,27 @@ inline Log4zStream & Log4zStream::writeULongLong(unsigned long long t, int width
802803
inline Log4zStream & Log4zStream::writeDouble(double t, bool isSimple)
803804
{
804805

805-
if (t != t)
806+
#if __cplusplus >= 201103L
807+
using std::isnan;
808+
using std::isinf;
809+
#endif
810+
if (isnan(t))
806811
{
807812
writeString("nan", 3);
808813
return *this;
809814
}
810-
else if (t <= 1.7976931348623158e+308 && t >= -1.7976931348623158e+308)
815+
else if (isinf(t))
811816
{
812817
writeString("inf", 3);
813818
return *this;
814819
}
815820

816821

822+
817823
size_t count = _end - _cur;
818824
double fabst = fabs(t);
819-
if (count > 30)
820-
{
825+
if (count > 30)
826+
{
821827
if ( fabst < 0.0001 || (!isSimple && fabst > 4503599627370495ULL) || (isSimple && fabst > 8388607))
822828
{
823829
gcvt(t, isSimple ? 7 : 16, _cur);
@@ -828,9 +834,9 @@ inline Log4zStream & Log4zStream::writeDouble(double t, bool isSimple)
828834
}
829835
else
830836
{
831-
if (t < 0.0)
832-
{
833-
writeChar('-');
837+
if (t < 0.0)
838+
{
839+
writeChar('-');
834840
}
835841
double intpart = 0;
836842
unsigned long long fractpart = (unsigned long long)(modf(fabst, &intpart) * 10000);
@@ -840,7 +846,7 @@ inline Log4zStream & Log4zStream::writeDouble(double t, bool isSimple)
840846
writeChar('.');
841847
writeULongLong(fractpart, 4);
842848
}
843-
}
849+
}
844850
}
845851

846852
return *this;

0 commit comments

Comments
 (0)