Skip to content

Commit 9f10094

Browse files
committed
docs(addon): setLogFilePath() method documented
1 parent a012dbc commit 9f10094

File tree

6 files changed

+23
-15
lines changed

6 files changed

+23
-15
lines changed

doc/api.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,14 @@ Usage: [usage/addon](usage.md#addon)
6969
languageSapToIso(langSapCode: string): string|Error
7070
```
7171

72+
### setLogFilePath
73+
74+
Usage: [usage/addon](usage.md#addon)
75+
76+
```ts
77+
setLogFilePath(langSapCode: string): string|Error
78+
```
79+
7280
## Client
7381

7482
Usage: [usage/client](usage.md#client)

src/cpp/Log.cc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ long long Log::timestamp() {
99
.count();
1010
}
1111

12-
void Log::set_log_file_name(const std::string& file_name) {
13-
log_fname = file_name;
12+
void Log::set_log_file_path(const std::string& file_path) {
13+
log_path = file_path;
1414
}
1515

1616
void Log::set_log_level(const logClass component_id,
@@ -43,9 +43,9 @@ void Log::set_log_level(const logClass component_id,
4343
set_log_level(component_id, log_level);
4444
}
4545

46-
Log::Log(std::string log_fname) : log_fname(log_fname) {
46+
Log::Log(std::string log_path) : log_path(log_path) {
4747
std::ofstream ofs;
48-
ofs.open(log_fname, std::ofstream::out | std::ofstream::trunc);
48+
ofs.open(log_path, std::ofstream::out | std::ofstream::trunc);
4949
ofs.close();
5050
}
5151

src/cpp/Log.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ enum class logLevel {
3737
class Log {
3838
private:
3939
// Log file name
40-
std::string log_fname;
40+
std::string log_path;
4141

4242
// Logging inactive by default
4343
std::unordered_map<logClass, logLevel> log_config = {
@@ -53,15 +53,15 @@ class Log {
5353

5454
public:
5555
// Set log file name
56-
void set_log_file_name(const std::string& file_name);
56+
void set_log_file_path(const std::string& file_path);
5757

5858
// Set log level
5959
void set_log_level(const logClass component_id, const logLevel log_level_id);
6060
void set_log_level(const logClass component_id,
6161
const Napi::Value logLevelValue);
6262

6363
// Default log filename
64-
explicit Log(std::string log_fname = "_noderfc.log");
64+
explicit Log(std::string log_path = "_noderfc.log");
6565
~Log();
6666

6767
// Write regular arguments. Must be defined in header becuse of variadic
@@ -85,7 +85,7 @@ class Log {
8585

8686
// Write log message
8787
ofstream ofs;
88-
ofs.open(log_fname.c_str(), ofstream::out | ios::app);
88+
ofs.open(log_path.c_str(), ofstream::out | ios::app);
8989
ofs << endl
9090
<< endl
9191
<< date::format("%F %T", now) << " UTC [" << timestamp() << "] >> "
@@ -105,7 +105,7 @@ class Log {
105105
if (log_level_id > log_config[component_id]) {
106106
return;
107107
}
108-
FILE* fp = fopen(log_fname.c_str(), "a");
108+
FILE* fp = fopen(log_path.c_str(), "a");
109109
fprintf(fp, "%s", "'");
110110
fprintfU(fp, message);
111111
fprintf(fp, "%s", "'");

src/cpp/addon.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,8 @@ Napi::Value LanguageSapToIso(const Napi::CallbackInfo& info) {
112112
return scope.Escape(wrapString(ucLangISO, 2));
113113
}
114114

115-
Napi::Value SetLogFileName(const Napi::CallbackInfo& info) {
116-
_log.set_log_file_name(info[0].As<Napi::String>().Utf8Value());
115+
Napi::Value SetLogFilePath(const Napi::CallbackInfo& info) {
116+
_log.set_log_file_path(info[0].As<Napi::String>().Utf8Value());
117117
return info.Env().Undefined();
118118
}
119119

@@ -123,7 +123,7 @@ Napi::Object RegisterModule(Napi::Env env, Napi::Object exports) {
123123
}
124124

125125
exports.Set("bindingVersions", BindingVersions(env));
126-
exports.Set("setLogFileName", Napi::Function::New(env, SetLogFileName));
126+
exports.Set("setLogFilePath", Napi::Function::New(env, SetLogFilePath));
127127
exports.Set("setIniFileDirectory",
128128
Napi::Function::New(env, SetIniFileDirectory));
129129
exports.Set("loadCryptoLibrary", Napi::Function::New(env, LoadCryptoLibrary));

src/ts/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ export function loadCryptoLibrary(libAbsolutePath: string) {
4646
noderfc_binding.loadCryptoLibrary(libAbsolutePath);
4747
}
4848

49-
export function setLogFileName(fileName: string) {
50-
noderfc_binding.setLogFileName(fileName);
49+
export function setLogFilePath(filePath: string) {
50+
noderfc_binding.setLogFilePath(filePath);
5151
}
5252

5353
export const sapnwrfcEvents = new EventEmitter();

src/ts/noderfc-bindings.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ export interface NWRfcBinding {
4343
languageIsoToSap(langIso: string): string | NWRfcSdkError;
4444
languageSapToIso(langSap: string): string | NWRfcSdkError;
4545
reloadIniFile(): undefined | NWRfcSdkError;
46-
setLogFileName(fileName: string): unknown;
46+
setLogFilePath(filePath: string): unknown;
4747
verbose(): this;
4848
}
4949

0 commit comments

Comments
 (0)