1use crate::POOL;
2
3#[cfg(any(feature = "fmt", feature = "fmt_no_tty"))]
5pub(crate) const FMT_MAX_COLS: &str = "POLARS_FMT_MAX_COLS";
6pub(crate) const FMT_MAX_ROWS: &str = "POLARS_FMT_MAX_ROWS";
7pub(crate) const FMT_STR_LEN: &str = "POLARS_FMT_STR_LEN";
8#[cfg(any(feature = "fmt", feature = "fmt_no_tty"))]
9pub(crate) const FMT_TABLE_CELL_ALIGNMENT: &str = "POLARS_FMT_TABLE_CELL_ALIGNMENT";
10#[cfg(any(feature = "fmt", feature = "fmt_no_tty"))]
11pub(crate) const FMT_TABLE_CELL_NUMERIC_ALIGNMENT: &str = "POLARS_FMT_TABLE_CELL_NUMERIC_ALIGNMENT";
12#[cfg(any(feature = "fmt", feature = "fmt_no_tty"))]
13pub(crate) const FMT_TABLE_DATAFRAME_SHAPE_BELOW: &str = "POLARS_FMT_TABLE_DATAFRAME_SHAPE_BELOW";
14#[cfg(any(feature = "fmt", feature = "fmt_no_tty"))]
15pub(crate) const FMT_TABLE_FORMATTING: &str = "POLARS_FMT_TABLE_FORMATTING";
16#[cfg(any(feature = "fmt", feature = "fmt_no_tty"))]
17pub(crate) const FMT_TABLE_HIDE_COLUMN_DATA_TYPES: &str = "POLARS_FMT_TABLE_HIDE_COLUMN_DATA_TYPES";
18#[cfg(any(feature = "fmt", feature = "fmt_no_tty"))]
19pub(crate) const FMT_TABLE_HIDE_COLUMN_NAMES: &str = "POLARS_FMT_TABLE_HIDE_COLUMN_NAMES";
20#[cfg(any(feature = "fmt", feature = "fmt_no_tty"))]
21pub(crate) const FMT_TABLE_HIDE_COLUMN_SEPARATOR: &str = "POLARS_FMT_TABLE_HIDE_COLUMN_SEPARATOR";
22#[cfg(any(feature = "fmt", feature = "fmt_no_tty"))]
23pub(crate) const FMT_TABLE_HIDE_DATAFRAME_SHAPE_INFORMATION: &str =
24 "POLARS_FMT_TABLE_HIDE_DATAFRAME_SHAPE_INFORMATION";
25#[cfg(any(feature = "fmt", feature = "fmt_no_tty"))]
26pub(crate) const FMT_TABLE_INLINE_COLUMN_DATA_TYPE: &str =
27 "POLARS_FMT_TABLE_INLINE_COLUMN_DATA_TYPE";
28#[cfg(any(feature = "fmt", feature = "fmt_no_tty"))]
29pub(crate) const FMT_TABLE_ROUNDED_CORNERS: &str = "POLARS_FMT_TABLE_ROUNDED_CORNERS";
30pub(crate) const FMT_TABLE_CELL_LIST_LEN: &str = "POLARS_FMT_TABLE_CELL_LIST_LEN";
31
32pub fn verbose() -> bool {
33 std::env::var("POLARS_VERBOSE").as_deref().unwrap_or("") == "1"
34}
35
36pub fn verbose_print_sensitive<F: Fn() -> String>(create_log_message: F) {
38 fn do_log(create_log_message: &dyn Fn() -> String) {
39 if std::env::var("POLARS_VERBOSE_SENSITIVE")
40 .as_deref()
41 .unwrap_or("")
42 == "1"
43 {
44 let msg = create_log_message().replace('\n', "");
46 eprintln!("[SENSITIVE]: {}", msg)
47 }
48 }
49
50 do_log(&create_log_message)
51}
52
53pub fn get_file_prefetch_size() -> usize {
54 std::env::var("POLARS_PREFETCH_SIZE")
55 .map(|s| s.parse::<usize>().expect("integer"))
56 .unwrap_or_else(|_| std::cmp::max(POOL.current_num_threads() * 2, 16))
57}
58
59pub fn get_rg_prefetch_size() -> usize {
60 std::env::var("POLARS_ROW_GROUP_PREFETCH_SIZE")
61 .map(|s| s.parse::<usize>().expect("integer"))
62 .unwrap_or_else(|_| std::cmp::max(get_file_prefetch_size(), 128))
64}
65
66pub fn force_async() -> bool {
67 std::env::var("POLARS_FORCE_ASYNC")
68 .map(|value| value == "1")
69 .unwrap_or_default()
70}