// Copyright (c) 2015 Spinpunch, Inc. All Rights Reserved. // See License.txt for license information. var Client = require('../../utils/client.jsx'); var AsyncClient = require('../../utils/async_client.jsx'); export default class LogSettings extends React.Component { constructor(props) { super(props); this.handleChange = this.handleChange.bind(this); this.handleSubmit = this.handleSubmit.bind(this); this.state = { consoleEnable: this.props.config.LogSettings.EnableConsole, fileEnable: this.props.config.LogSettings.EnableFile, saveNeeded: false, serverError: null }; } handleChange(action) { var s = {saveNeeded: true, serverError: this.state.serverError}; if (action === 'console_true') { s.consoleEnable = true; } if (action === 'console_false') { s.consoleEnable = false; } if (action === 'file_true') { s.fileEnable = true; } if (action === 'file_false') { s.fileEnable = false; } this.setState(s); } handleSubmit(e) { e.preventDefault(); $('#save-button').button('loading'); var config = this.props.config; config.LogSettings.EnableConsole = React.findDOMNode(this.refs.consoleEnable).checked; config.LogSettings.ConsoleLevel = React.findDOMNode(this.refs.consoleLevel).value; config.LogSettings.EnableFile = React.findDOMNode(this.refs.fileEnable).checked; config.LogSettings.FileLevel = React.findDOMNode(this.refs.fileLevel).value; config.LogSettings.FileLocation = React.findDOMNode(this.refs.fileLocation).value.trim(); config.LogSettings.FileFormat = React.findDOMNode(this.refs.fileFormat).value.trim(); Client.saveConfig( config, () => { AsyncClient.getConfig(); this.setState({ consoleEnable: config.LogSettings.EnableConsole, fileEnable: config.LogSettings.EnableFile, serverError: null, saveNeeded: false }); $('#save-button').button('reset'); }, (err) => { this.setState({ consoleEnable: config.LogSettings.EnableConsole, fileEnable: config.LogSettings.EnableFile, serverError: err.message, saveNeeded: true }); $('#save-button').button('reset'); } ); } render() { var serverError = ''; if (this.state.serverError) { serverError =
; } var saveClass = 'btn'; if (this.state.saveNeeded) { saveClass = 'btn btn-primary'; } return (

{'Log Settings'}

{'Typically set to false in production. Developers may set this field to true to output log messages to console based on the console level option. If true then the server will output messages to the standard output stream (stdout).'}

{'This setting determines the level of detail at which log events are written to the console. ERROR: Outputs only error messages. INFO: Outputs error messages and information around startup and initialization. DEBUG: Prints high detail for developers debugging issues working on debugging issues.'}

{'Typically set to true in production. When true log files are written to the file specified in file location field below.'}

{'This setting determines the level of detail at which log events are written to the file. ERROR: Outputs only error messages. INFO: Outputs error messages and information around startup and initialization. DEBUG: Prints high detail for developers debugging issues working on debugging issues.'}

{'File to which log files are written. If blank, will be set to ./logs/mattermost.log. Log rotation is enabled and new files may be created in the same directory.'}

{'Format of log message output. If blank will be set to "[%D %T] [%L] %M", where:'}

{'%T'}{'Time (15:04:05 MST)'}
{'%D'}{'Date (2006/01/02)'}
{'%d'}{'Date (01/02/06)'}
{'%L'}{'Level (DEBG, INFO, EROR)'}
{'%S'}{'Source'}
{'%M'}{'Message'}

{serverError}
); } } LogSettings.propTypes = { config: React.PropTypes.object };