PICout improvement:

* renamed private members for more clear code
 * registerExternalBufferID() method to obtain unique ID for withExternalBuffer()
 * PICoutManipulators::PICoutStdStream enum for select stream (stdout or stderr)
 * Constructors now accept optional stream
 * piCerr and piCerrObj macros

PIDir::temporary() moved to "mkdtemp"

PILog:
 * now 4 levels
 * you can set max level
 * Error writes to piCerr
This commit is contained in:
2024-09-16 16:06:07 +03:00
parent 9d4357c066
commit 000ce2a54d
11 changed files with 357 additions and 320 deletions

View File

@@ -459,7 +459,7 @@ PIDir PIDir::current() {
PIDir PIDir::home() {
#ifndef ESP_PLATFORM
char * rc = 0;
char * rc = nullptr;
#endif
#ifdef WINDOWS
rc = new char[1024];
@@ -482,7 +482,7 @@ PIDir PIDir::home() {
#else
# ifndef ESP_PLATFORM
rc = getenv("HOME");
if (rc == 0) return PIDir();
if (!rc) return PIDir();
return PIDir(rc);
# else
return PIDir();
@@ -492,7 +492,7 @@ PIDir PIDir::home() {
PIDir PIDir::temporary() {
char * rc = 0;
char * rc = nullptr;
#ifdef WINDOWS
rc = new char[1024];
memset(rc, 0, 1024);
@@ -507,8 +507,8 @@ PIDir PIDir::temporary() {
s.prepend(separator);
return PIDir(s);
#else
rc = tmpnam(0);
if (rc == 0) return PIDir();
rc = mkdtemp("/tmp/pidir_tmp_XXXXXX");
if (!rc) return PIDir();
PIString s(rc);
return PIDir(s.left(s.findLast(PIDir::separator)));
#endif