Skip to content

Commit

Permalink
Fix ConsoleLogger, update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
zenden2k committed Feb 20, 2024
1 parent 23f49aa commit c4e5568
Show file tree
Hide file tree
Showing 10 changed files with 33 additions and 22 deletions.
4 changes: 2 additions & 2 deletions Dist/DocGen/examples/example.nut
Expand Up @@ -12,7 +12,7 @@ function UploadFile(pathToFile, options) {
nm.doUploadMultipartData();

local response = nm.responseBody(); // 'local' it's like javascript's 'var' but only for local variables
local directUrl = regex_simple(response, "\\[IMG\\](.+)\\[/IMG\\]",0);
local directUrl = _RegexSimple(response, "\\[IMG\\](.+)\\[/IMG\\]",0);

options.setDirectUrl(directUrl);

Expand All @@ -27,7 +27,7 @@ function UploadFile(pathToFile, options) {
// @param int start - starting position
// @return string - returns text captured by the first subpattern.
//
function regex_simple(data,regStr,start) {
function _RegexSimple(data,regStr,start) {
local ex = regexp(regStr);
local res = ex.capture(data, start);
local resultStr = "";
Expand Down
3 changes: 2 additions & 1 deletion Dist/DocGen/examples/gumbo_query.nut
@@ -1,4 +1,5 @@
local txt = "<h1><a id=\"logo\">some link</a></h1>";
local txt = "<h1><a id=\"logo\" class=\"link\">some link</a></h1>";

local doc = Document(txt);
print(doc.find("h1 a").text()+"\r\n");
print(doc.find("h1 a").length()+"\r\n");
Expand Down
8 changes: 4 additions & 4 deletions Dist/DocGen/implement.h
@@ -1,10 +1,10 @@
/**
@file
@section Implement Functions to implement
You have to implement at least one function — <code>UploadFile</code>.<br>
If your service supports authentication, you have to implement <code>Authenticate</code> function.
If you want to support album listing/creating/modifying, you have to implement also <code>GetFolderList</code>, <code>CreateFolder</code>,
<code>ModifyFolder</code>, <code>GetFolderAccessTypeList</code></i>.</p>
You have to implement at least one function — \ref UploadFile.<br>
If your service supports authentication, you have to implement \ref Authenticate function.
If you want to support album listing/creating/modifying, you have to implement also \ref GetFolderList, \ref CreateFolder,
\ref ModifyFolder, \ref GetFolderAccessTypeList</i>.</p>
*/

/**
Expand Down
8 changes: 5 additions & 3 deletions Dist/DocGen/mainpage.h
Expand Up @@ -24,14 +24,16 @@ Squirrel is a high level imperative, object-oriented programming language, desig
@section Example Example
@include example.nut
<p>
You have to implement at least one function — <code>UploadFile</code>.<br>
If you want to support album listing/creating/modifying, you have to implement also <code>GetFolderList</code>, <code>CreateFolder</code>,
<code>ModifyFolder</code>, <code>GetFolderAccessTypeList</code>.</p>
You have to implement at least one function — \ref UploadFile.<br>
If you want to support album listing/creating/modifying, you have to implement also \ref GetFolderList, \ref CreateFolder,
\ref ModifyFolder, \ref GetFolderAccessTypeList.</p>
<code>nm</code> - global object - is an instance of NetworkClient<br>
<code>ServerParams</code> - global object - is an instance of ServerSettingsStruct
<p>
@section ParsingHtml Parsing HTML with gumbo-query
Gumbo-query is a library that provides CSS selector-like queries for Gumbo-Parser.
Use \ref ScriptAPI::Document class.
@include gumbo_query.nut
*/
5 changes: 4 additions & 1 deletion Source/Core/3rdpart/GumboQuery/Selection.h
Expand Up @@ -36,11 +36,14 @@ class CSelection: public CObject
CSelection& each(std::function<void(int, CNode)> callback);
/* @endcond */
CSelection& squirrelEach(Sqrat::Function callback);
public:


CSelection find(std::string aSelector);

CNode at(unsigned int i);
/* @cond PRIVATE */
CNode nodeAt(unsigned int i);
/* @endcond */

unsigned int nodeNum();

Expand Down
8 changes: 4 additions & 4 deletions Source/Core/Logging/ConsoleLogger.cpp
Expand Up @@ -7,21 +7,21 @@
#include "Core/Utils/ConsoleUtils.h"


void ConsoleLogger::write(LogMsgType MsgType, const std::string& FileName, const std::string& Sender, const std::string& Msg, const std::string& Info) {
void ConsoleLogger::write(LogMsgType MsgType, const std::string& Sender, const std::string& Msg, const std::string& Info, const std::string& FileName) {
std::lock_guard<std::mutex> guard(ConsoleUtils::instance()->getOutputMutex());
//#ifdef _WIN32
std::wcerr << IuCoreUtils::Utf8ToWstring(Msg) << std::endl;
std::wcerr << std::endl << IuCoreUtils::Utf8ToWstring(Msg) << std::endl;
/*#else
std::cerr << IuCoreUtils::Utf8ToSystemLocale(Msg) << std::endl;
#endif*/
}

#ifdef _WIN32
void ConsoleLogger::write(LogMsgType MsgType, const wchar_t* FileName, const wchar_t* Sender, const wchar_t* Msg, const wchar_t* Info) {
void ConsoleLogger::write(LogMsgType MsgType, const wchar_t* Sender, const wchar_t* Msg, const wchar_t* Info, const wchar_t* FileName) {
std::lock_guard<std::mutex> guard(ConsoleUtils::instance()->getOutputMutex());
std::cerr << ( MsgType == logError ? "error" : "warning" ) << " : ";
//#ifdef _WIN32
std::wcerr << Msg << std::endl;
std::wcerr << std::endl << Msg << std::endl;
/*#else
std::cerr << IuCoreUtils::Utf8ToSystemLocale(IuCoreUtils::WstringToUtf8(Msg)) << std::endl;
#endif*/
Expand Down
6 changes: 3 additions & 3 deletions Source/Core/Logging/ConsoleLogger.h
Expand Up @@ -7,10 +7,10 @@

class ConsoleLogger : public ILogger {
public:
void write(LogMsgType MsgType, const std::string& FileName, const std::string& Sender, const std::string& Msg, const std::string& Info) override;
void write(LogMsgType MsgType, const std::string& Info, const std::string& Sender, const std::string& Msg, const std::string& FileName) override;
#ifdef _WIN32
void write(LogMsgType MsgType, const wchar_t* FileName, const wchar_t* Sender, const wchar_t* Msg, const wchar_t* Info) override;
void write(LogMsgType MsgType, const wchar_t* Info, const wchar_t* Sender, const wchar_t* Msg, const wchar_t* FileName) override;
#endif
};

#endif
#endif
4 changes: 2 additions & 2 deletions Source/Core/Network/NetworkClient.h
Expand Up @@ -35,11 +35,11 @@
class CurlShare;

/**
@brief HTTP/FTP client (libcurl wrapper).
@brief Network client (libcurl wrapper).
Note: After each completed request, most of the options are set to default values.
In scripts: nm - a global instance of NetworkClient
In .nut scripts: "nm" is a global instance of NetworkClient
*/
class NetworkClient: public INetworkClient
{
Expand Down
7 changes: 6 additions & 1 deletion Source/Core/Scripting/API/Functions.h
Expand Up @@ -419,6 +419,11 @@ namespace ScriptAPI {

std::string GetDeviceId();
std::string GetDeviceName();

/**
* @param type message severity (possible values: "error", "warning", "info")
*/
void WriteLog(const std::string& type, const std::string& message);
}

#endif
#endif
2 changes: 1 addition & 1 deletion Source/Core/Upload/UploadEngine.h
Expand Up @@ -184,7 +184,7 @@ class ServerSettingsStruct
* Login
* Password
*
* Custom parameters which should be visible in server settings dialog, should have the same name as in GetServerParamList.
* Custom parameters which should be visible in server settings dialog, should have the same name as in \ref GetServerParamList.
*/
std::string getParam(const std::string& name)
{
Expand Down

0 comments on commit c4e5568

Please sign in to comment.