cryptolinx

Console

cryptolinx Telah dikemas kini   
๐Ÿ“• Console Library


๐Ÿ”ท Introduction

This script is an adaptation of the classic JavaScript console script. It provides a simple way to display data in a console-like table format for debugging purposes.

While there are many nice console/logger scripts out there, my personal goal was to achieve inline functionality and visual object (label, lines) logging.



๐Ÿ”ท How to Use

โ—ผ 1. Import the Console library into your script:

import cryptolinx/Console/1

- or -

Instead of the library namespace, you can define a custom namespace as alias.

import cryptolinx/Console/1 as c



โ—ผ 2. Create and init a new `<terminal>` object.

The `init()` method is used to initialize the console object with default settings. It can be used to customize it.

// When using the `var` keyword in a declaration, the logs will act as ever-forwarding.
// Without `var`, the `console` variable will be redeclared every time `bar` is called.

// var console = Console.terminal.new(log_position=position.bottom_left, prefix = '> ', show_no = true)

- or -

If you has set up an alias before.

var console = c.terminal.new().init()



โ—ผ 3. Logging

// inline โœจ
array <float> testArray = array.new<float>(3, .0).log(console)
// basic
console.log(testArray)

// inline โœจ
var testLabel = label.new(bar_index, close, 'Label Text').log(console)
// basic
console.log(testLabel)

// It is also possible to use `().` for literals โœจ.
int a = 100
testCalc = (5 * 100).log(console) + a.log(console) // SUM: 600

console.
.empty()
.log('SUM' + WS + testCalc.tostring())



โ—ผ 4. Visibility

Finally, we need to call the `show()` method to display the logged messages in the console.

console.show(true) // True by default. Simply turn it on or off
Nota Keluaran:
๐Ÿ”ท v2

- Included missing data types, enabling logging of any type except tables while including arrays/matrices.
The log() method now offers four different variants, each corresponding to a possible type.

console.log(testArray, [optional level])
console.log('Array Data:', testArray, [optional level], [optional delimiter])
testArray.log(console, [optional level])


- If you only require a string representation, you can utilize the .toString() function, which is available for all types except tables, including arrays/matrices.
Introduced new temporary options: opt_textColor, opt_bgColor, and opt_textSize.

console.log('Array Data:', testArray).opt_textColor(color.blue)
console.log(testFloat).opt_textSize(size.normal)
console.log(testLabel).opt_bgColor(color.blue)
Nota Keluaran:
๐Ÿ”ท v3

โœจ Enhanced Functionality
One of the key additions is the introduction of `_prefix`, `_delimiter`, `_lvl` options to all variants of the `log()` function. Now you have greater flexibility and control over how your logs are displayed.

๐Ÿ“š Updated Documentation
To make your experience even better, I've revamped my documentation. You'll find NEW BADGES that provide useful information and make it easier to navigate through the documentation.

๐Ÿ†• Additional Methods
I listened to your feedback! In response, I have included the previously missing `.tostring()` method for ``, `array`, `linefill`, `array ` and matrix.
You can now convert them into `` representations effortlessly.

โœ… Supported Types

With these updates, I've achieved comprehensive support for all types, excluding ``. You can now log and stringify allmost anything with ease.

Simply use:
console.log(data,[...options])
data.log(console, [...options])
or directly invoke `data.tostring()`.


Here's a quick recap of the supported types:
, , , , , , , , ,
array, array, array, array, array, array, array, array, array,
matrix, matrix, matrix, matrix, matrix, matrix, matrix, matrix, matrix.

โ›” Unsupported Types:
, array, matrix.

Your feedback and suggestions have been invaluable in shaping a big part of my scripts, so please keep them coming.

Thank you for your continued support!
Nota Keluaran:
๐Ÿ”ท v4

Updated the function arguments to address a known override issue that occurs when logging an integer with a prefix in function calls. In result, I have separated the log level from the main `log()` function. You can now set the log level by using the `opt_lvl(int)` function.
Nota Keluaran:
๐Ÿ”ท v5

๐Ÿ› Bug Fixes
  • Column 0 is out of table bounds: A big thank you to @doqkhanh for reporting this issue. I've fixed the bug. Now, both initialization methods with and without var are working perfectly

โœจ Enhancements
  • Script Documentation Update: I've updated the script documentation to enhance your experience. Please note that currently, multiline function arguments break the custom documentation on hovering, so I've reformatted it to single lines.

๐Ÿ“‘I'm dedicated to offering the best possible experience with this library. Your feedback and reports are always welcome. ๐Ÿ˜Š
Nota Keluaran:
๐Ÿ”ท v6

๐Ÿ› Bug Fixes
  • FIXED: Inline Color Function
  • FIXED: Offset Error

๐Ÿ†• New Stuff
  • Formatted Tooltip Output for Arrays and Matrices
  • Support for new built-in type: chart.point
Nota Keluaran:
๐Ÿ”ท v7

๐ŸŽ‰ Exciting New Features

๐Ÿ†• Hybrid Logs: Added Support for the New Native Logging Feature

  • Introducing a new way to log data with hybrid logs, enhancing the flexibility and control of your logging experience.
  • Added a new string field to the terminal object called display, allowing you to specify where the logs should be displayed. Options include 'all', 'chart', 'logs'. Default is set to 'all'.
  • This feature enables more targeted logging, allowing you to choose the appropriate display method for your specific use case.

๐Ÿ†• New Log Variant: Direct Logging to the App Log Window
  • Now you can log directly to the app's native log window, providing a streamlined and efficient logging process.
  • This direct logging variant automatically converts all supported native types to strings, making it easier to log data without the need for manual conversion.
  • Ideal for simple logging tasks where direct access to the native log window is preferred.

โœจ As Short As Simple
// New direct logging to the app log window without a terminal object.
myVar.log()
myArray.log()
label.all.log(2)   // Log Level: 2 warning

๐Ÿ“‘ Continuous Improvement
As always, I'm committed to providing the best experience with this library. These new features are designed to enhance your logging capabilities and offer more flexibility in how you interact with logs. Your feedback and suggestions are highly valued, and I look forward to hearing how these updates enhance your development process. ๐Ÿ˜Š
Nota Keluaran:
๐Ÿ”ท v8

๐Ÿ› Bug Fix
  • FIXED: Wrong data return
Perpustakaan Pine

Di dalam semangat sebenar TradingView, pengarang telah menerbitkan kod Pine ini sebagai perpustakaan sumber terbuka, jadi pengaturcara-pengaturcara Pine yang lain dari komuniti kami boleh menggunakannya semula. Sorakan kepada penulis! Anda boleh menggunakan perpustakaan ini secara peribadi atau pada penerbitan-penerbitan sumber terbuka lain, tetapi penggunaan semula kod ini di dalam penerbitan adalah ditadbir oleh Peraturan Dalaman.

Penafian

Maklumat dan penerbitan adalah tidak dimaksudkan untuk menjadi, dan tidak membentuk, nasihat untuk kewangan, pelaburan, perdagangan dan jenis-jenis lain atau cadangan yang dibekalkan atau disahkan oleh TradingView. Baca dengan lebih lanjut di Terma Penggunaan.

Mahu gunakan perpustakaan ini?

Salin garisan ini dan tampalkan ia di dalam skrip anda.