Skip to content

Commit 319eb83

Browse files
authored
log: add log.use_stdout(), use it to silence the transition note for the most commonly used V tools/examples (#23642)
1 parent 23c3af8 commit 319eb83

File tree

12 files changed

+24
-7
lines changed

12 files changed

+24
-7
lines changed

ci/common/runner.v

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ pub fn (t Task) run() {
3434

3535
pub fn run(all_tasks map[string]Task) {
3636
unbuffer_stdout()
37+
log.use_stdout()
3738
if os.args.len < 2 {
3839
println('Usage: v run macos_ci.vsh <task_name>')
3940
println('Available tasks are: ${all_tasks.keys()}')

cmd/tools/fast/fast.v

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ fn lexec(cmd string) string {
4141

4242
fn main() {
4343
// ensure all log messages will be visible to the observers, even if the program panics
44+
log.use_stdout()
4445
log.set_always_flush(true)
4546

4647
total_sw := time.new_stopwatch()

cmd/tools/gen_vc.v

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ struct FlagOptions {
9797
}
9898

9999
fn main() {
100+
log.use_stdout()
100101
mut fp := flag.new_flag_parser(os.args.clone())
101102
fp.application(app_name)
102103
fp.version(app_version)

cmd/tools/vcover/main.v

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@ fn normalize_path(path string) string {
148148
}
149149

150150
fn main() {
151+
log.use_stdout()
151152
mut ctx := Context{}
152153
ctx.working_folder = normalize_path(os.real_path(os.getwd()))
153154
mut fp := flag.new_flag_parser(os.args#[1..])

cmd/tools/vdownload.v

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,7 @@ mut:
2323
const vexe = os.real_path(os.getenv_opt('VEXE') or { @VEXE })
2424

2525
fn main() {
26-
mut l := log.ThreadSafeLog{}
27-
l.set_output_stream(os.stdout())
28-
log.set_logger(l)
26+
log.use_stdout()
2927
mut ctx := Context{}
3028
mut fp := flag.new_flag_parser(os.args#[1..])
3129
fp.application(os.file_name(os.executable()))

cmd/tools/vretry_test.v

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ fn run(cmd string) os.Result {
2222
}
2323

2424
fn test_retry() {
25+
log.use_stdout()
2526
log.warn('start...')
2627
defer {
2728
log.warn('... done')

cmd/tools/vshould-compile-all.v

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import log
44
const should_clean = os.args.contains('-c')
55

66
fn main() {
7+
log.use_stdout()
78
mut files := []string{}
89
args := os.args#[2..].filter(it != '-c')
910
for a in args {

examples/pendulum-simulation/animation.v

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import sim.args as simargs
88

99
fn main() {
1010
unbuffer_stdout()
11+
log.use_stdout()
1112
args := simargs.parse_args(extra_workers: 1)! as simargs.ParallelArgs
1213
mut app := anim.new_app(args)
1314
mut workers := []thread{cap: args.workers}

examples/poll_coindesk_bitcoin_vs_usd_rate.v

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import net.http
77
const url = 'https://api.coindesk.com/v1/bpi/currentprice.json'
88

99
fn main() {
10+
log.use_stdout()
1011
mut old_rate := f64(0)
1112
for i := u64(1); true; i++ {
1213
data := http.get(url) or {

examples/veb/websocket/server.v

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import net.websocket
1212
const app_port = 8990
1313

1414
fn main() {
15+
log.use_stdout()
1516
mut app := &App{
1617
wss: new_websocker_server()!
1718
}
@@ -64,6 +65,7 @@ fn wlog(message string) {
6465
fn new_websocker_server() !&websocket.Server {
6566
mut logger := &log.Log{}
6667
logger.set_level(.info)
68+
logger.set_output_stream(os.stderr())
6769
mut wss := websocket.new_server(.ip, app_port, '', logger: logger)
6870
wss.set_ping_interval(100)
6971
wss.on_connect(fn [mut logger] (mut server_client websocket.ServerClient) !bool {

0 commit comments

Comments
 (0)