Skip to content

Commit

Permalink
rename log.nu to lg.nu
Browse files Browse the repository at this point in the history
  • Loading branch information
nashvi committed Mar 30, 2024
1 parent 1658af9 commit 23704d1
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
14 changes: 7 additions & 7 deletions modules/kubernetes/kubernetes.nu
Original file line number Diff line number Diff line change
Expand Up @@ -1071,7 +1071,7 @@ export def 'kube refine' [
...namespace: string@"nu-complete kube ns"
--kind(-k): list<string@"nu-complete kube kind">
] {
use log.nu
use lg.nu
let config = $env.KUBERNETES_REFINE

let nsf = if ($namespace | is-empty) {
Expand All @@ -1089,27 +1089,27 @@ export def 'kube refine' [

mut data = []
if ($namespace | is-empty) {
log level 4 {stage: cluster}
lg level 4 {stage: cluster}
for p in ($config.cluster_resources | transpose k v) {
if $p.k not-in $resource { continue }
log level 3 {kind: $p.k} list
lg level 3 {kind: $p.k} list
let rs = kubectl get $p.k | from ssv -a | get NAME
for r in $rs {
log level 1 {kind: $p.k, name: $r} collect
lg level 1 {kind: $p.k, name: $r} collect
let obj = kubectl get $p.k $r --output=json | from json
let pyl = refine $p.v $obj
$data ++= $pyl
}
}
}
log level 4 {stage: namespace}
lg level 4 {stage: namespace}
for p in ($config.resources | transpose k v) {
if $p.k not-in $resource { continue }
for ns in $cns {
log level 2 {kind: $p.k, ns: $ns} list
lg level 2 {kind: $p.k, ns: $ns} list
let rs = kubectl get $p.k --namespace $ns | from ssv -a | get NAME
for r in $rs {
log level 0 {kind: $p.k, ns: $ns, name: $r} collect
lg level 0 {kind: $p.k, ns: $ns, name: $r} collect
let obj = kubectl get $p.k --namespace $ns $r --output=json | from json
let pyl = refine $p.v $obj
$data ++= $pyl
Expand Down
18 changes: 9 additions & 9 deletions modules/kubernetes/log.nu → modules/kubernetes/lg.nu
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
def get_settings [] {
{
level: ($env.nlog_level? | default 2)
file: ($env.nlog_file?)
level: ($env.lg_level? | default 2)
file: ($env.lg_file?)
}
}

export-env {
$env.nlog_prefix = ['TRC' 'DBG' 'INF' 'WRN' 'ERR' 'CRT']
$env.nlog_prefix_index = {
$env.lg_prefix = ['TRC' 'DBG' 'INF' 'WRN' 'ERR' 'CRT']
$env.lg_prefix_index = {
trc: 0
dbg: 1
inf: 2 msg: 2
wrn: 3
err: 4
crt: 5
}
$env.nlog_theme = {
$env.lg_theme = {
default: {
level : (['navy' 'teal' 'xgreen' 'xpurplea' 'olive' 'maroon'] | each { ansi $in })
delimiter: $'(ansi grey39)│'
Expand Down Expand Up @@ -56,7 +56,7 @@ export def --wrapped level [
] {
let setting = if ($setting | is-empty) { get_settings } else { $setting }
let theme = if ($setting.file? | is-empty) { 'default' } else { 'colorless' }
let theme = $env.nlog_theme | get $theme
let theme = $env.lg_theme | get $theme
let output = if ($setting.file? | is-empty) {{ print -e $in }} else {{ $in | save -af $setting.file }}
let msg = parse_msg $args

Expand Down Expand Up @@ -85,7 +85,7 @@ export def --wrapped level [
}

def 'nu-complete log-prefix' [] {
$env.nlog_prefix_index | columns
$env.lg_prefix_index | columns
}

export def --wrapped main [
Expand All @@ -94,11 +94,11 @@ export def --wrapped main [
...args
] {
let setting = get_settings
let lv = $env.nlog_prefix_index | get $level
let lv = $env.lg_prefix_index | get $level
if $lv < $setting.level {
return
}
let label = $env.nlog_prefix | get $lv
let label = $env.lg_prefix | get $lv
if $multiline {
level $lv ...$args --label $label --setting $setting --multiline
} else {
Expand Down

0 comments on commit 23704d1

Please sign in to comment.