Proyectos de Subversion Moodle

Rev

| Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1 efrain 1
// This file is part of Moodle - http://moodle.org/
2
//
3
// Moodle is free software: you can redistribute it and/or modify
4
// it under the terms of the GNU General Public License as published by
5
// the Free Software Foundation, either version 3 of the License, or
6
// (at your option) any later version.
7
//
8
// Moodle is distributed in the hope that it will be useful,
9
// but WITHOUT ANY WARRANTY; without even the implied warranty of
10
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11
// GNU General Public License for more details.
12
//
13
// You should have received a copy of the GNU General Public License
14
// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
15
 
16
/**
17
 * Default reactive mutations logger class.
18
 *
19
 * This logger is used by default by the StateManager to log mutation feedbacks
20
 * and actions. By default, feedbacks will be displayed as a toast. However, the
21
 * reactive instance can provide alternative loggers to provide advanced logging
22
 * capabilities.
23
 *
24
 * @module     core/local/reactive/logger
25
 * @class      Logger
26
 * @copyright  2023 Ferran Recio <ferran@moodle.com>
27
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
28
 */
29
 
30
/**
31
 * Logger entry structure.
32
 *
33
 * @typedef {object} LoggerEntry
34
 * @property {string} feedbackMessage Feedback message.
35
 */
36
 
37
import {add as addToast} from 'core/toast';
38
 
39
/**
40
 * Default reactive mutations logger class.
41
 * @class Logger
42
 */
43
export default class Logger {
44
    /**
45
     * Constructor.
46
     */
47
    constructor() {
48
        this._debug = false;
49
    }
50
 
51
    /**
52
     * Add a log entry.
53
     * @param {LoggerEntry} entry Log entry.
54
     */
55
    add(entry) {
56
        if (entry.feedbackMessage) {
57
            addToast(entry.feedbackMessage);
58
        }
59
    }
60
}