1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 |
- /**
- * @license
- * Visual Blocks Language
- *
- * Copyright 2012 Google Inc.
- * https://developers.google.com/blockly/
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
- /**
- * @fileoverview Generating Python for colour blocks.
- * @author fraser@google.com (Neil Fraser)
- */
- 'use strict';
- goog.provide('Blockly.Python.log');
- goog.require('Blockly.Python');
- Blockly.Python['log_setup'] = function(block) {
- // Colour picker.
- var code = 'import logging\n';
- return code;
- };
- Blockly.Python['log_conf'] = function(block) {
- // Colour picker.
- var code = 'logging.basicConfig(\n'+
- ' level=logging.INFO,\n'+
- ' format="[%(asctime)s] %(levelname)s:%(name)s:%(message)s"\n'+
- ')\n';
- return code;
- };
- Blockly.Python['log_import'] = function(block) {
- var code = "import logging\n"
- return code;
- }
- Blockly.Python['log_info'] = function(block) {
- var var_arg0 = Blockly.Python.valueToCode(block, 'LOG_INPUT',
- Blockly.Python.ORDER_NONE) || '___';
- var code = "logging.info("+ var_arg0 + ")\n";
- return code;
- }
- Blockly.Python['log_config'] = function(block) {
- var level = block.getFieldValue("LEVEL");
- var code = "logging.basicConfig(level="+level+")\n";
- return code;
- }
|