log.js 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. /**
  2. * @license
  3. * Visual Blocks Editor
  4. *
  5. * Copyright 2012 Google Inc.
  6. * https://developers.google.com/blockly/
  7. *
  8. * Licensed under the Apache License, Version 2.0 (the "License");
  9. * you may not use this file except in compliance with the License.
  10. * You may obtain a copy of the License at
  11. *
  12. * http://www.apache.org/licenses/LICENSE-2.0
  13. *
  14. * Unless required by applicable law or agreed to in writing, software
  15. * distributed under the License is distributed on an "AS IS" BASIS,
  16. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  17. * See the License for the specific language governing permissions and
  18. * limitations under the License.
  19. */
  20. /**
  21. * @fileoverview Colour blocks for Blockly.
  22. * @author fraser@google.com (Neil Fraser)
  23. */
  24. 'use strict';
  25. goog.provide('Blockly.Blocks.log');
  26. goog.require('Blockly.Blocks');
  27. /**
  28. * Common HSV hue for all blocks in this category.
  29. */
  30. Blockly.Blocks.log.HUE = 45;
  31. Blockly.Blocks['log_setup'] = {
  32. /**
  33. * Block for log setup.
  34. * @this Blockly.Block
  35. */
  36. init: function() {
  37. this.setColour(Blockly.Blocks.log.HUE);
  38. this.appendDummyInput()
  39. .appendField(Blockly.Msg.LOGGING_SETUP);
  40. // this.setInputsInline(false);
  41. // this.setOutput(true);
  42. this.setPreviousStatement(true);
  43. this.setNextStatement(true);
  44. },
  45. };
  46. Blockly.Blocks['log_conf'] = {
  47. /**
  48. * Block for log setup.
  49. * @this Blockly.Block
  50. */
  51. init: function() {
  52. this.setColour(Blockly.Blocks.log.HUE);
  53. this.appendDummyInput()
  54. .appendField(Blockly.Msg.LOGGING_CONF);
  55. // this.setInputsInline(false);
  56. // this.setOutput(true);
  57. this.setPreviousStatement(true);
  58. this.setNextStatement(true);
  59. },
  60. };
  61. Blockly.Blocks['log_import'] = {
  62. /**
  63. * Block for log import.
  64. * @this Blockly.Block
  65. */
  66. init: function() {
  67. this.setColour(Blockly.Blocks.log.HUE);
  68. this.appendDummyInput()
  69. .appendField(Blockly.Msg.LOGGING_IMPORT);
  70. // this.setInputsInline(false);
  71. // this.setOutput(true);
  72. this.setPreviousStatement(true);
  73. this.setNextStatement(true);
  74. },
  75. }
  76. Blockly.Blocks['log_info'] = {
  77. /**
  78. * Block for log info.
  79. * @this Blockly.Block
  80. */
  81. init: function() {
  82. this.setColour(Blockly.Blocks.log.HUE);
  83. this.appendValueInput("LOG_INPUT")
  84. .appendField(Blockly.Msg.LOGGING_INFO);
  85. this.setInputsInline(false);
  86. // this.setOutput(true);
  87. this.setPreviousStatement(true);
  88. this.setNextStatement(true);
  89. },
  90. }
  91. Blockly.Blocks['log_config'] = {
  92. /**
  93. * Block for log setup.
  94. * @this Blockly.Block
  95. */
  96. init: function() {
  97. this.setColour(Blockly.Blocks.log.HUE);
  98. this.appendDummyInput()
  99. .appendField(Blockly.Msg.LOGGING_CONFIG)
  100. this.appendDummyInput()
  101. .appendField(Blockly.Msg.LOGGING_CONFIG_LEVEL)
  102. .appendField(new Blockly.FieldDropdown([
  103. ["INFO","logging.INFO"],
  104. ["ERROR","logging.ERROR"],
  105. ["WARNING","logging.WARNING"],
  106. ["CRITICAL","logging.CRITICAL"],
  107. ["DEBUG","logging.DEBUG"],
  108. ["NOTSET","logging.NOTSET"],
  109. ]),"LEVEL")
  110. this.setInputsInline(false);
  111. // this.setOutput(true);
  112. this.setPreviousStatement(true);
  113. this.setNextStatement(true);
  114. },
  115. }