This repository has been archived by the owner on Jul 24, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Set NODESASS_TRACE enviroment variable to any value to get lots of output.
- Loading branch information
Showing
3 changed files
with
66 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#include <stdio.h> | ||
#include <sstream> | ||
|
||
#include <uv.h> | ||
|
||
#include "debug.h" | ||
|
||
Log::Log() {} | ||
|
||
std::ostringstream& Log::Get(TLogLevel level, void *p, const char *f, const char *filen, int lineno) | ||
{ | ||
os << "[NODESASS@" << uv_thread_self() << "] " << p << ":" << f << " " << filen << ":" << lineno << " "; | ||
messageLevel = level; | ||
return os; | ||
} | ||
std::ostringstream& Log::Get(TLogLevel level, const char *f, const char *filen, int lineno) | ||
{ | ||
os << "[NODESASS@" << uv_thread_self() << "] " << f << " " << filen << ":" << lineno << " "; | ||
messageLevel = level; | ||
return os; | ||
} | ||
Log::~Log() | ||
{ | ||
os << std::endl; | ||
fprintf(stderr, "%s", os.str().c_str()); | ||
fflush(stderr); | ||
} |
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 |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#ifndef NODE_SASS_DEBUG_H | ||
#define NODE_SASS_DEBUG_H | ||
|
||
#include <sstream> | ||
|
||
enum TLogLevel {logINFO, logTRACE}; | ||
static TLogLevel LogReportingLevel = getenv("NODESASS_TRACE") ? logTRACE : logINFO; | ||
class Log | ||
{ | ||
public: | ||
Log(); | ||
virtual ~Log(); | ||
std::ostringstream& Get(TLogLevel level, void *p, const char *f, const char *filen, int lineno); | ||
std::ostringstream& Get(TLogLevel level, const char *f, const char *filen, int lineno); | ||
public: | ||
protected: | ||
std::ostringstream os; | ||
private: | ||
Log(const Log&); | ||
Log& operator =(const Log&); | ||
private: | ||
TLogLevel messageLevel; | ||
}; | ||
|
||
// Visual Studio 2013 does not like __func__ | ||
#if _MSC_VER < 1900 | ||
#define __func__ __FUNCTION__ | ||
#endif | ||
|
||
#define TRACE() \ | ||
if (logTRACE > LogReportingLevel) ; \ | ||
else Log().Get(logTRACE, __func__, __FILE__, __LINE__) | ||
|
||
#define TRACEINST(obj) \ | ||
if (logTRACE > LogReportingLevel) ; \ | ||
else Log().Get(logTRACE, (obj), __func__, __FILE__, __LINE__) | ||
|
||
#endif |