forked from VeriBlock/nodecore-pow-cuda-miner
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
16c4bcb
commit afd29cc
Showing
7 changed files
with
2,193 additions
and
1,904 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,98 +1,100 @@ | ||
#pragma once | ||
#pragma comment(lib,"Ws2_32.lib") | ||
#pragma comment(lib, "Ws2_32.lib") | ||
|
||
#include <fstream> | ||
#include <chrono> | ||
#include <cstring> | ||
#include <iostream> | ||
#include <string> | ||
|
||
#ifdef _WIN32 | ||
#include <Windows.h> | ||
#elif __linux__ | ||
#define boolean bool | ||
#define byte uint8_t | ||
#endif | ||
#include <iostream> | ||
#include <string> | ||
#include <chrono> | ||
|
||
#define LOG_FILE "cuda-miner.log" | ||
|
||
using namespace std; | ||
|
||
class Log { | ||
private: | ||
public: | ||
static inline bool& log() | ||
{ | ||
static bool opt = true; | ||
return opt; | ||
} | ||
// TODO(mks): Rework logging. | ||
extern bool verboseOutput; | ||
extern char outputBuffer[8192]; | ||
extern void vprintf(char* toprint); | ||
extern void promptExit(int exitCode); | ||
|
||
static void setEnabled(bool enabled) { | ||
log() = enabled; | ||
} | ||
|
||
static void info(char* toLog) { | ||
if (log()) { | ||
static std::ofstream logfile; | ||
logfile = ofstream(); | ||
logfile.open(LOG_FILE, ios::app | ios::out); | ||
logfile.write(toLog, strlen(toLog)); | ||
logfile.write("\n", 2); | ||
logfile.close(); | ||
} | ||
} | ||
class Log { | ||
public: | ||
static inline bool& log() { | ||
static bool opt = true; | ||
return opt; | ||
} | ||
|
||
static void info(string &toLog) { | ||
if (log()) { | ||
static std::ofstream logfile; | ||
logfile = ofstream(); | ||
logfile.open(LOG_FILE, ios::app | ios::out); | ||
logfile << toLog << endl; | ||
logfile.close(); | ||
} | ||
} | ||
static void setEnabled(bool enabled) { log() = enabled; } | ||
|
||
static void warn(char* toLog) { | ||
if (log()) { | ||
static std::ofstream logfile; | ||
logfile = ofstream(); | ||
logfile.open(LOG_FILE, ios::app | ios::out); | ||
logfile.write("[WARN] ", 8); | ||
logfile.write(toLog, strlen(toLog)); | ||
logfile.write("\n", 2); | ||
logfile.close(); | ||
} | ||
} | ||
static void info(char* toLog) { | ||
if (log()) { | ||
static std::ofstream logfile; | ||
logfile = ofstream(); | ||
logfile.open(LOG_FILE, ios::app | ios::out); | ||
logfile.write(toLog, strlen(toLog)); | ||
logfile.write("\n", 2); | ||
logfile.close(); | ||
} | ||
} | ||
|
||
static void warn(string &toLog) { | ||
if (log()) { | ||
static std::ofstream logfile; | ||
logfile = ofstream(); | ||
logfile.open(LOG_FILE, ios::app | ios::out); | ||
logfile << "[WARN] " << toLog << endl; | ||
logfile.close(); | ||
} | ||
} | ||
static void info(string& toLog) { | ||
if (log()) { | ||
static std::ofstream logfile; | ||
logfile = ofstream(); | ||
logfile.open(LOG_FILE, ios::app | ios::out); | ||
logfile << toLog << endl; | ||
logfile.close(); | ||
} | ||
} | ||
|
||
static void warn(char* toLog) { | ||
if (log()) { | ||
static std::ofstream logfile; | ||
logfile = ofstream(); | ||
logfile.open(LOG_FILE, ios::app | ios::out); | ||
logfile.write("[WARN] ", 8); | ||
logfile.write(toLog, strlen(toLog)); | ||
logfile.write("\n", 2); | ||
logfile.close(); | ||
} | ||
} | ||
|
||
static void error(char* toLog) { | ||
if (log()) { | ||
static std::ofstream logfile; | ||
logfile = ofstream(); | ||
logfile.open(LOG_FILE, ios::app | ios::out); | ||
logfile.write("[ERROR] ", 9); | ||
logfile.write(toLog, strlen(toLog)); | ||
logfile.write("\n", 2); | ||
logfile.close(); | ||
} | ||
} | ||
static void warn(string& toLog) { | ||
if (log()) { | ||
static std::ofstream logfile; | ||
logfile = ofstream(); | ||
logfile.open(LOG_FILE, ios::app | ios::out); | ||
logfile << "[WARN] " << toLog << endl; | ||
logfile.close(); | ||
} | ||
} | ||
|
||
static void error(char* toLog) { | ||
if (log()) { | ||
static std::ofstream logfile; | ||
logfile = ofstream(); | ||
logfile.open(LOG_FILE, ios::app | ios::out); | ||
logfile.write("[ERROR] ", 9); | ||
logfile.write(toLog, strlen(toLog)); | ||
logfile.write("\n", 2); | ||
logfile.close(); | ||
} | ||
} | ||
|
||
static void error(string &toLog) { | ||
if (log()) { | ||
static std::ofstream logfile; | ||
logfile = ofstream(); | ||
logfile.open(LOG_FILE, ios::app | ios::out); | ||
logfile << "[ERROR] " << toLog << endl; | ||
logfile.close(); | ||
} | ||
} | ||
static void error(string& toLog) { | ||
if (log()) { | ||
static std::ofstream logfile; | ||
logfile = ofstream(); | ||
logfile.open(LOG_FILE, ios::app | ios::out); | ||
logfile << "[ERROR] " << toLog << endl; | ||
logfile.close(); | ||
} | ||
} | ||
}; |
Oops, something went wrong.