Line data Source code
1 : /*
2 : * SPDX-License-Identifier: GPL-3.0-only
3 : * MuseScore-CLA-applies
4 : *
5 : * MuseScore Studio
6 : * Music Composition & Notation
7 : *
8 : * Copyright (C) 2021 MuseScore Limited and others
9 : *
10 : * This program is free software: you can redistribute it and/or modify
11 : * it under the terms of the GNU General Public License version 3 as
12 : * published by the Free Software Foundation.
13 : *
14 : * This program is distributed in the hope that it will be useful,
15 : * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 : * GNU General Public License for more details.
18 : *
19 : * You should have received a copy of the GNU General Public License
20 : * along with this program. If not, see <https://www.gnu.org/licenses/>.
21 : */
22 : #include "logapi.h"
23 :
24 : #include "log.h"
25 :
26 : using namespace muse::api;
27 :
28 : /** APIDOC
29 : * Write messages to log and console
30 : * @namespace Log
31 : * @example
32 : * const Log = require("MuseApi.Log");
33 : *
34 : * function main() {
35 : * Log.info("called main function")
36 : * }
37 : */
38 0 : LogApi::LogApi(api::IApiEngine* e)
39 0 : : ApiObject(e)
40 : {
41 0 : }
42 :
43 : /** APIDOC
44 : * Write error message with default tag
45 : * @method
46 : * @param {String} message Message
47 : */
48 0 : void LogApi::error(const QString& message)
49 : {
50 0 : error("Api", message);
51 0 : }
52 :
53 : /** APIDOC
54 : * Write warning message with default tag
55 : * @method
56 : * @param {String} message Message
57 : */
58 0 : void LogApi::warn(const QString& message)
59 : {
60 0 : warn("Api", message);
61 0 : }
62 :
63 : /** APIDOC
64 : * Write info message with default tag
65 : * @method
66 : * @param {String} message Message
67 : */
68 0 : void LogApi::info(const QString& message)
69 : {
70 0 : info("Api", message);
71 0 : }
72 :
73 : /** APIDOC
74 : * Write debug message with default tag
75 : * @method
76 : * @param {String} message Message
77 : */
78 0 : void LogApi::debug(const QString& message)
79 : {
80 0 : debug("Api", message);
81 0 : }
82 :
83 : /** APIDOC
84 : * Write error message with tag
85 : * @method
86 : * @param {String} tag Tag
87 : * @param {String} message Message
88 : */
89 0 : void LogApi::error(const QString& tag, const QString& message)
90 : {
91 0 : LOGE_T(tag.toStdString())() << message;
92 0 : }
93 :
94 : /** APIDOC
95 : * Write warning message with tag
96 : * @method
97 : * @param {String} tag Tag
98 : * @param {String} message Message
99 : */
100 0 : void LogApi::warn(const QString& tag, const QString& message)
101 : {
102 0 : LOGW_T(tag.toStdString())() << message;
103 0 : }
104 :
105 : /** APIDOC
106 : * Write info message with tag
107 : * @method
108 : * @param {String} tag Tag
109 : * @param {String} message Message
110 : */
111 0 : void LogApi::info(const QString& tag, const QString& message)
112 : {
113 0 : LOGI_T(tag.toStdString())() << message;
114 0 : }
115 :
116 : /** APIDOC
117 : * Write debug message with tag
118 : * @method
119 : * @param {String} tag Tag
120 : * @param {String} message Message
121 : */
122 0 : void LogApi::debug(const QString& tag, const QString& message)
123 : {
124 0 : LOGD_T(tag.toStdString())() << message;
125 0 : }
|