Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

71 lines
1.7 KiB

  1. @echo off
  2. REM ------------------------------------------------------------------
  3. REM
  4. REM logmsg.cmd
  5. REM Logs text messages to the screen and/or in a log file
  6. REM
  7. REM Copyright (c) Microsoft Corporation. All rights reserved.
  8. REM
  9. REM ------------------------------------------------------------------
  10. perl -x "%~f0" %*
  11. goto :EOF
  12. #!perl
  13. use strict;
  14. use lib $ENV{RAZZLETOOLPATH};
  15. use ParseArgs;
  16. use Logmsg;
  17. sub Usage { print<<USAGE; exit(1) }
  18. Prints the given string to the screen and into a file.
  19. Used by command scripts to log messages.
  20. usage: logmsg.cmd < message | \@filename > [logfile]
  21. /t If specified, the message is timestamped.
  22. message Specifies the text to be logged, should
  23. be quoted.
  24. filename A filename preceeded by an at-sign (\@)
  25. may be given instead of a message. The
  26. contents will be appened into the log
  27. if the given file exists.
  28. logfile Specifies the name of the log file.
  29. LOGFILE, if defined, is the default.
  30. If this parameter is not specified and
  31. LOGFILE is not defined, the message is
  32. displayed on the screen only.
  33. ex: call logmsg.cmd "This is the message to display."
  34. call logmsg.cmd \@mylog.txt
  35. USAGE
  36. my ($message, $logfile, $timestamp);
  37. parseargs('?' => \&Usage,
  38. 't' => \$timestamp,
  39. \$message,
  40. \$logfile);
  41. if ($logfile) {
  42. $ENV{LOGFILE} = $logfile;
  43. }
  44. $ENV{SCRIPT_NAME} ||= '????';
  45. if ($message =~ /^\@(.*)/) {
  46. if (-e $1) {
  47. append_file($1);
  48. }
  49. else {
  50. # do nothing if file to append does not exist
  51. }
  52. }
  53. elsif ($timestamp) {
  54. timemsg $message;
  55. }
  56. else {
  57. logmsg $message;
  58. }